mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-30 12:27:29 +09:00
import FIREFOX_52_6_0esr_RELEASE from mozilla-esr52 hg repo
This commit is contained in:
commit
dcd9973243
150858 changed files with 23884658 additions and 0 deletions
5
nsprpub/.cvsignore
Normal file
5
nsprpub/.cvsignore
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
Makefile
|
||||
config-defs.h
|
||||
config.cache
|
||||
config.log
|
||||
config.status
|
||||
373
nsprpub/LICENSE
Normal file
373
nsprpub/LICENSE
Normal file
|
|
@ -0,0 +1,373 @@
|
|||
Mozilla Public License Version 2.0
|
||||
==================================
|
||||
|
||||
1. Definitions
|
||||
--------------
|
||||
|
||||
1.1. "Contributor"
|
||||
means each individual or legal entity that creates, contributes to
|
||||
the creation of, or owns Covered Software.
|
||||
|
||||
1.2. "Contributor Version"
|
||||
means the combination of the Contributions of others (if any) used
|
||||
by a Contributor and that particular Contributor's Contribution.
|
||||
|
||||
1.3. "Contribution"
|
||||
means Covered Software of a particular Contributor.
|
||||
|
||||
1.4. "Covered Software"
|
||||
means Source Code Form to which the initial Contributor has attached
|
||||
the notice in Exhibit A, the Executable Form of such Source Code
|
||||
Form, and Modifications of such Source Code Form, in each case
|
||||
including portions thereof.
|
||||
|
||||
1.5. "Incompatible With Secondary Licenses"
|
||||
means
|
||||
|
||||
(a) that the initial Contributor has attached the notice described
|
||||
in Exhibit B to the Covered Software; or
|
||||
|
||||
(b) that the Covered Software was made available under the terms of
|
||||
version 1.1 or earlier of the License, but not also under the
|
||||
terms of a Secondary License.
|
||||
|
||||
1.6. "Executable Form"
|
||||
means any form of the work other than Source Code Form.
|
||||
|
||||
1.7. "Larger Work"
|
||||
means a work that combines Covered Software with other material, in
|
||||
a separate file or files, that is not Covered Software.
|
||||
|
||||
1.8. "License"
|
||||
means this document.
|
||||
|
||||
1.9. "Licensable"
|
||||
means having the right to grant, to the maximum extent possible,
|
||||
whether at the time of the initial grant or subsequently, any and
|
||||
all of the rights conveyed by this License.
|
||||
|
||||
1.10. "Modifications"
|
||||
means any of the following:
|
||||
|
||||
(a) any file in Source Code Form that results from an addition to,
|
||||
deletion from, or modification of the contents of Covered
|
||||
Software; or
|
||||
|
||||
(b) any new file in Source Code Form that contains any Covered
|
||||
Software.
|
||||
|
||||
1.11. "Patent Claims" of a Contributor
|
||||
means any patent claim(s), including without limitation, method,
|
||||
process, and apparatus claims, in any patent Licensable by such
|
||||
Contributor that would be infringed, but for the grant of the
|
||||
License, by the making, using, selling, offering for sale, having
|
||||
made, import, or transfer of either its Contributions or its
|
||||
Contributor Version.
|
||||
|
||||
1.12. "Secondary License"
|
||||
means either the GNU General Public License, Version 2.0, the GNU
|
||||
Lesser General Public License, Version 2.1, the GNU Affero General
|
||||
Public License, Version 3.0, or any later versions of those
|
||||
licenses.
|
||||
|
||||
1.13. "Source Code Form"
|
||||
means the form of the work preferred for making modifications.
|
||||
|
||||
1.14. "You" (or "Your")
|
||||
means an individual or a legal entity exercising rights under this
|
||||
License. For legal entities, "You" includes any entity that
|
||||
controls, is controlled by, or is under common control with You. For
|
||||
purposes of this definition, "control" means (a) the power, direct
|
||||
or indirect, to cause the direction or management of such entity,
|
||||
whether by contract or otherwise, or (b) ownership of more than
|
||||
fifty percent (50%) of the outstanding shares or beneficial
|
||||
ownership of such entity.
|
||||
|
||||
2. License Grants and Conditions
|
||||
--------------------------------
|
||||
|
||||
2.1. Grants
|
||||
|
||||
Each Contributor hereby grants You a world-wide, royalty-free,
|
||||
non-exclusive license:
|
||||
|
||||
(a) under intellectual property rights (other than patent or trademark)
|
||||
Licensable by such Contributor to use, reproduce, make available,
|
||||
modify, display, perform, distribute, and otherwise exploit its
|
||||
Contributions, either on an unmodified basis, with Modifications, or
|
||||
as part of a Larger Work; and
|
||||
|
||||
(b) under Patent Claims of such Contributor to make, use, sell, offer
|
||||
for sale, have made, import, and otherwise transfer either its
|
||||
Contributions or its Contributor Version.
|
||||
|
||||
2.2. Effective Date
|
||||
|
||||
The licenses granted in Section 2.1 with respect to any Contribution
|
||||
become effective for each Contribution on the date the Contributor first
|
||||
distributes such Contribution.
|
||||
|
||||
2.3. Limitations on Grant Scope
|
||||
|
||||
The licenses granted in this Section 2 are the only rights granted under
|
||||
this License. No additional rights or licenses will be implied from the
|
||||
distribution or licensing of Covered Software under this License.
|
||||
Notwithstanding Section 2.1(b) above, no patent license is granted by a
|
||||
Contributor:
|
||||
|
||||
(a) for any code that a Contributor has removed from Covered Software;
|
||||
or
|
||||
|
||||
(b) for infringements caused by: (i) Your and any other third party's
|
||||
modifications of Covered Software, or (ii) the combination of its
|
||||
Contributions with other software (except as part of its Contributor
|
||||
Version); or
|
||||
|
||||
(c) under Patent Claims infringed by Covered Software in the absence of
|
||||
its Contributions.
|
||||
|
||||
This License does not grant any rights in the trademarks, service marks,
|
||||
or logos of any Contributor (except as may be necessary to comply with
|
||||
the notice requirements in Section 3.4).
|
||||
|
||||
2.4. Subsequent Licenses
|
||||
|
||||
No Contributor makes additional grants as a result of Your choice to
|
||||
distribute the Covered Software under a subsequent version of this
|
||||
License (see Section 10.2) or under the terms of a Secondary License (if
|
||||
permitted under the terms of Section 3.3).
|
||||
|
||||
2.5. Representation
|
||||
|
||||
Each Contributor represents that the Contributor believes its
|
||||
Contributions are its original creation(s) or it has sufficient rights
|
||||
to grant the rights to its Contributions conveyed by this License.
|
||||
|
||||
2.6. Fair Use
|
||||
|
||||
This License is not intended to limit any rights You have under
|
||||
applicable copyright doctrines of fair use, fair dealing, or other
|
||||
equivalents.
|
||||
|
||||
2.7. Conditions
|
||||
|
||||
Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
|
||||
in Section 2.1.
|
||||
|
||||
3. Responsibilities
|
||||
-------------------
|
||||
|
||||
3.1. Distribution of Source Form
|
||||
|
||||
All distribution of Covered Software in Source Code Form, including any
|
||||
Modifications that You create or to which You contribute, must be under
|
||||
the terms of this License. You must inform recipients that the Source
|
||||
Code Form of the Covered Software is governed by the terms of this
|
||||
License, and how they can obtain a copy of this License. You may not
|
||||
attempt to alter or restrict the recipients' rights in the Source Code
|
||||
Form.
|
||||
|
||||
3.2. Distribution of Executable Form
|
||||
|
||||
If You distribute Covered Software in Executable Form then:
|
||||
|
||||
(a) such Covered Software must also be made available in Source Code
|
||||
Form, as described in Section 3.1, and You must inform recipients of
|
||||
the Executable Form how they can obtain a copy of such Source Code
|
||||
Form by reasonable means in a timely manner, at a charge no more
|
||||
than the cost of distribution to the recipient; and
|
||||
|
||||
(b) You may distribute such Executable Form under the terms of this
|
||||
License, or sublicense it under different terms, provided that the
|
||||
license for the Executable Form does not attempt to limit or alter
|
||||
the recipients' rights in the Source Code Form under this License.
|
||||
|
||||
3.3. Distribution of a Larger Work
|
||||
|
||||
You may create and distribute a Larger Work under terms of Your choice,
|
||||
provided that You also comply with the requirements of this License for
|
||||
the Covered Software. If the Larger Work is a combination of Covered
|
||||
Software with a work governed by one or more Secondary Licenses, and the
|
||||
Covered Software is not Incompatible With Secondary Licenses, this
|
||||
License permits You to additionally distribute such Covered Software
|
||||
under the terms of such Secondary License(s), so that the recipient of
|
||||
the Larger Work may, at their option, further distribute the Covered
|
||||
Software under the terms of either this License or such Secondary
|
||||
License(s).
|
||||
|
||||
3.4. Notices
|
||||
|
||||
You may not remove or alter the substance of any license notices
|
||||
(including copyright notices, patent notices, disclaimers of warranty,
|
||||
or limitations of liability) contained within the Source Code Form of
|
||||
the Covered Software, except that You may alter any license notices to
|
||||
the extent required to remedy known factual inaccuracies.
|
||||
|
||||
3.5. Application of Additional Terms
|
||||
|
||||
You may choose to offer, and to charge a fee for, warranty, support,
|
||||
indemnity or liability obligations to one or more recipients of Covered
|
||||
Software. However, You may do so only on Your own behalf, and not on
|
||||
behalf of any Contributor. You must make it absolutely clear that any
|
||||
such warranty, support, indemnity, or liability obligation is offered by
|
||||
You alone, and You hereby agree to indemnify every Contributor for any
|
||||
liability incurred by such Contributor as a result of warranty, support,
|
||||
indemnity or liability terms You offer. You may include additional
|
||||
disclaimers of warranty and limitations of liability specific to any
|
||||
jurisdiction.
|
||||
|
||||
4. Inability to Comply Due to Statute or Regulation
|
||||
---------------------------------------------------
|
||||
|
||||
If it is impossible for You to comply with any of the terms of this
|
||||
License with respect to some or all of the Covered Software due to
|
||||
statute, judicial order, or regulation then You must: (a) comply with
|
||||
the terms of this License to the maximum extent possible; and (b)
|
||||
describe the limitations and the code they affect. Such description must
|
||||
be placed in a text file included with all distributions of the Covered
|
||||
Software under this License. Except to the extent prohibited by statute
|
||||
or regulation, such description must be sufficiently detailed for a
|
||||
recipient of ordinary skill to be able to understand it.
|
||||
|
||||
5. Termination
|
||||
--------------
|
||||
|
||||
5.1. The rights granted under this License will terminate automatically
|
||||
if You fail to comply with any of its terms. However, if You become
|
||||
compliant, then the rights granted under this License from a particular
|
||||
Contributor are reinstated (a) provisionally, unless and until such
|
||||
Contributor explicitly and finally terminates Your grants, and (b) on an
|
||||
ongoing basis, if such Contributor fails to notify You of the
|
||||
non-compliance by some reasonable means prior to 60 days after You have
|
||||
come back into compliance. Moreover, Your grants from a particular
|
||||
Contributor are reinstated on an ongoing basis if such Contributor
|
||||
notifies You of the non-compliance by some reasonable means, this is the
|
||||
first time You have received notice of non-compliance with this License
|
||||
from such Contributor, and You become compliant prior to 30 days after
|
||||
Your receipt of the notice.
|
||||
|
||||
5.2. If You initiate litigation against any entity by asserting a patent
|
||||
infringement claim (excluding declaratory judgment actions,
|
||||
counter-claims, and cross-claims) alleging that a Contributor Version
|
||||
directly or indirectly infringes any patent, then the rights granted to
|
||||
You by any and all Contributors for the Covered Software under Section
|
||||
2.1 of this License shall terminate.
|
||||
|
||||
5.3. In the event of termination under Sections 5.1 or 5.2 above, all
|
||||
end user license agreements (excluding distributors and resellers) which
|
||||
have been validly granted by You or Your distributors under this License
|
||||
prior to termination shall survive termination.
|
||||
|
||||
************************************************************************
|
||||
* *
|
||||
* 6. Disclaimer of Warranty *
|
||||
* ------------------------- *
|
||||
* *
|
||||
* Covered Software is provided under this License on an "as is" *
|
||||
* basis, without warranty of any kind, either expressed, implied, or *
|
||||
* statutory, including, without limitation, warranties that the *
|
||||
* Covered Software is free of defects, merchantable, fit for a *
|
||||
* particular purpose or non-infringing. The entire risk as to the *
|
||||
* quality and performance of the Covered Software is with You. *
|
||||
* Should any Covered Software prove defective in any respect, You *
|
||||
* (not any Contributor) assume the cost of any necessary servicing, *
|
||||
* repair, or correction. This disclaimer of warranty constitutes an *
|
||||
* essential part of this License. No use of any Covered Software is *
|
||||
* authorized under this License except under this disclaimer. *
|
||||
* *
|
||||
************************************************************************
|
||||
|
||||
************************************************************************
|
||||
* *
|
||||
* 7. Limitation of Liability *
|
||||
* -------------------------- *
|
||||
* *
|
||||
* Under no circumstances and under no legal theory, whether tort *
|
||||
* (including negligence), contract, or otherwise, shall any *
|
||||
* Contributor, or anyone who distributes Covered Software as *
|
||||
* permitted above, be liable to You for any direct, indirect, *
|
||||
* special, incidental, or consequential damages of any character *
|
||||
* including, without limitation, damages for lost profits, loss of *
|
||||
* goodwill, work stoppage, computer failure or malfunction, or any *
|
||||
* and all other commercial damages or losses, even if such party *
|
||||
* shall have been informed of the possibility of such damages. This *
|
||||
* limitation of liability shall not apply to liability for death or *
|
||||
* personal injury resulting from such party's negligence to the *
|
||||
* extent applicable law prohibits such limitation. Some *
|
||||
* jurisdictions do not allow the exclusion or limitation of *
|
||||
* incidental or consequential damages, so this exclusion and *
|
||||
* limitation may not apply to You. *
|
||||
* *
|
||||
************************************************************************
|
||||
|
||||
8. Litigation
|
||||
-------------
|
||||
|
||||
Any litigation relating to this License may be brought only in the
|
||||
courts of a jurisdiction where the defendant maintains its principal
|
||||
place of business and such litigation shall be governed by laws of that
|
||||
jurisdiction, without reference to its conflict-of-law provisions.
|
||||
Nothing in this Section shall prevent a party's ability to bring
|
||||
cross-claims or counter-claims.
|
||||
|
||||
9. Miscellaneous
|
||||
----------------
|
||||
|
||||
This License represents the complete agreement concerning the subject
|
||||
matter hereof. If any provision of this License is held to be
|
||||
unenforceable, such provision shall be reformed only to the extent
|
||||
necessary to make it enforceable. Any law or regulation which provides
|
||||
that the language of a contract shall be construed against the drafter
|
||||
shall not be used to construe this License against a Contributor.
|
||||
|
||||
10. Versions of the License
|
||||
---------------------------
|
||||
|
||||
10.1. New Versions
|
||||
|
||||
Mozilla Foundation is the license steward. Except as provided in Section
|
||||
10.3, no one other than the license steward has the right to modify or
|
||||
publish new versions of this License. Each version will be given a
|
||||
distinguishing version number.
|
||||
|
||||
10.2. Effect of New Versions
|
||||
|
||||
You may distribute the Covered Software under the terms of the version
|
||||
of the License under which You originally received the Covered Software,
|
||||
or under the terms of any subsequent version published by the license
|
||||
steward.
|
||||
|
||||
10.3. Modified Versions
|
||||
|
||||
If you create software not governed by this License, and you want to
|
||||
create a new license for such software, you may create and use a
|
||||
modified version of this License if you rename the license and remove
|
||||
any references to the name of the license steward (except to note that
|
||||
such modified license differs from this License).
|
||||
|
||||
10.4. Distributing Source Code Form that is Incompatible With Secondary
|
||||
Licenses
|
||||
|
||||
If You choose to distribute Source Code Form that is Incompatible With
|
||||
Secondary Licenses under the terms of this version of the License, the
|
||||
notice described in Exhibit B of this License must be attached.
|
||||
|
||||
Exhibit A - Source Code Form License Notice
|
||||
-------------------------------------------
|
||||
|
||||
This Source Code Form is subject to the terms of the Mozilla Public
|
||||
License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
If it is not possible or desirable to put the notice in a particular
|
||||
file, then You may include the notice in a location (such as a LICENSE
|
||||
file in a relevant directory) where a recipient would be likely to look
|
||||
for such a notice.
|
||||
|
||||
You may add additional accurate notices of copyright ownership.
|
||||
|
||||
Exhibit B - "Incompatible With Secondary Licenses" Notice
|
||||
---------------------------------------------------------
|
||||
|
||||
This Source Code Form is "Incompatible With Secondary Licenses", as
|
||||
defined by the Mozilla Public License, v. 2.0.
|
||||
118
nsprpub/Makefile.in
Normal file
118
nsprpub/Makefile.in
Normal file
|
|
@ -0,0 +1,118 @@
|
|||
#! gmake
|
||||
|
||||
#
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
|
||||
MOD_DEPTH = .
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(MOD_DEPTH)/config/autoconf.mk
|
||||
|
||||
DIRS = config pr lib
|
||||
|
||||
ifdef MOZILLA_CLIENT
|
||||
# Make nsinstall use absolute symlinks by default for Mozilla OSX builds
|
||||
# http://bugzilla.mozilla.org/show_bug.cgi?id=193164
|
||||
ifeq ($(OS_ARCH),Darwin)
|
||||
ifndef NSDISTMODE
|
||||
NSDISTMODE=absolute_symlink
|
||||
export NSDISTMODE
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
DIST_GARBAGE = config.cache config.log config.status
|
||||
|
||||
all:: config.status export
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
config.status:: configure
|
||||
ifeq ($(OS_ARCH),WINNT)
|
||||
sh $(srcdir)/configure --no-create --no-recursion
|
||||
else
|
||||
./config.status --recheck && ./config.status
|
||||
endif
|
||||
|
||||
#
|
||||
# The -ll option of zip converts CR LF to LF.
|
||||
#
|
||||
ifeq ($(OS_ARCH),WINNT)
|
||||
ZIP_ASCII_OPT = -ll
|
||||
endif
|
||||
|
||||
# Delete config/autoconf.mk last because it is included by every makefile.
|
||||
distclean::
|
||||
@echo "cd pr/tests; $(MAKE) $@"
|
||||
@$(MAKE) -C pr/tests $@
|
||||
rm -f config/autoconf.mk
|
||||
rm -f `cat unallmakefiles` unallmakefiles
|
||||
|
||||
release::
|
||||
echo $(BUILD_NUMBER) > $(RELEASE_DIR)/$(BUILD_NUMBER)/version.df
|
||||
@if test -f imports.df; then \
|
||||
echo "cp -f imports.df $(RELEASE_DIR)/$(BUILD_NUMBER)/imports.df"; \
|
||||
cp -f imports.df $(RELEASE_DIR)/$(BUILD_NUMBER)/imports.df; \
|
||||
else \
|
||||
echo "echo > $(RELEASE_DIR)/$(BUILD_NUMBER)/imports.df"; \
|
||||
echo > $(RELEASE_DIR)/$(BUILD_NUMBER)/imports.df; \
|
||||
fi
|
||||
cd $(RELEASE_DIR)/$(BUILD_NUMBER)/$(OBJDIR_NAME); \
|
||||
rm -rf META-INF; mkdir META-INF; cd META-INF; \
|
||||
echo "Manifest-Version: 1.0" > MANIFEST.MF; \
|
||||
echo "" >> MANIFEST.MF; \
|
||||
cd ..; rm -f mdbinary.jar; zip -r mdbinary.jar META-INF bin lib; \
|
||||
rm -rf META-INF; \
|
||||
cd include; \
|
||||
rm -rf META-INF; mkdir META-INF; cd META-INF; \
|
||||
echo "Manifest-Version: 1.0" > MANIFEST.MF; \
|
||||
echo "" >> MANIFEST.MF; \
|
||||
cd ..; rm -f mdheader.jar; zip $(ZIP_ASCII_OPT) -r mdheader.jar *; \
|
||||
rm -rf META-INF
|
||||
ifeq ($(OS_ARCH),WINNT)
|
||||
@if test ! -d $(MDIST)/$(MOD_NAME)/$(BUILD_NUMBER); then \
|
||||
rm -rf $(MDIST)/$(MOD_NAME)/$(BUILD_NUMBER); \
|
||||
echo "making directory $(MDIST)/$(MOD_NAME)/$(BUILD_NUMBER)"; \
|
||||
mkdir -p $(MDIST)/$(MOD_NAME)/$(BUILD_NUMBER); \
|
||||
fi
|
||||
@if test ! -d $(MDIST)/$(MOD_NAME)/$(BUILD_NUMBER)/$(RELEASE_OBJDIR_NAME); then \
|
||||
rm -rf $(MDIST)/$(MOD_NAME)/$(BUILD_NUMBER)/$(RELEASE_OBJDIR_NAME); \
|
||||
echo "making directory $(MDIST)/$(MOD_NAME)/$(BUILD_NUMBER)/$(RELEASE_OBJDIR_NAME)"; \
|
||||
mkdir -p $(MDIST)/$(MOD_NAME)/$(BUILD_NUMBER)/$(RELEASE_OBJDIR_NAME); \
|
||||
fi
|
||||
else
|
||||
@if test ! -d $(MDIST)/$(MOD_NAME)/$(BUILD_NUMBER); then \
|
||||
rm -rf $(MDIST)/$(MOD_NAME)/$(BUILD_NUMBER); \
|
||||
echo "making directory $(MDIST)/$(MOD_NAME)/$(BUILD_NUMBER)"; \
|
||||
$(NSINSTALL) -D $(MDIST)/$(MOD_NAME)/$(BUILD_NUMBER); \
|
||||
chmod 775 $(MDIST)/$(MOD_NAME)/$(BUILD_NUMBER); \
|
||||
fi
|
||||
@if test ! -d $(MDIST)/$(MOD_NAME)/$(BUILD_NUMBER)/$(RELEASE_OBJDIR_NAME); then \
|
||||
rm -rf $(MDIST)/$(MOD_NAME)/$(BUILD_NUMBER)/$(RELEASE_OBJDIR_NAME); \
|
||||
echo "making directory $(MDIST)/$(MOD_NAME)/$(BUILD_NUMBER)/$(RELEASE_OBJDIR_NAME)"; \
|
||||
$(NSINSTALL) -D $(MDIST)/$(MOD_NAME)/$(BUILD_NUMBER)/$(RELEASE_OBJDIR_NAME); \
|
||||
chmod 775 $(MDIST)/$(MOD_NAME)/$(BUILD_NUMBER)/$(RELEASE_OBJDIR_NAME); \
|
||||
fi
|
||||
endif
|
||||
cd $(RELEASE_DIR)/$(BUILD_NUMBER); \
|
||||
cp -f version.df imports.df $(MDIST)/$(MOD_NAME)/$(BUILD_NUMBER); \
|
||||
chmod 664 $(MDIST)/$(MOD_NAME)/$(BUILD_NUMBER)/version.df; \
|
||||
chmod 664 $(MDIST)/$(MOD_NAME)/$(BUILD_NUMBER)/imports.df; \
|
||||
cd $(OBJDIR_NAME); \
|
||||
cp -f mdbinary.jar $(MDIST)/$(MOD_NAME)/$(BUILD_NUMBER)/$(RELEASE_OBJDIR_NAME); \
|
||||
chmod 664 $(MDIST)/$(MOD_NAME)/$(BUILD_NUMBER)/$(RELEASE_OBJDIR_NAME)/mdbinary.jar; \
|
||||
cd include; \
|
||||
cp -f mdheader.jar $(MDIST)/$(MOD_NAME)/$(BUILD_NUMBER)/$(RELEASE_OBJDIR_NAME); \
|
||||
chmod 664 $(MDIST)/$(MOD_NAME)/$(BUILD_NUMBER)/$(RELEASE_OBJDIR_NAME)/mdheader.jar
|
||||
|
||||
package:
|
||||
@echo "cd pkg; $(MAKE) publish"
|
||||
$(MAKE) -C pkg publish
|
||||
|
||||
depend:
|
||||
@echo "NSPR20 has no dependencies. Skipped."
|
||||
1
nsprpub/TAG-INFO
Normal file
1
nsprpub/TAG-INFO
Normal file
|
|
@ -0,0 +1 @@
|
|||
NSPR_4_13_1_RTM
|
||||
43
nsprpub/admin/explode.pl
Normal file
43
nsprpub/admin/explode.pl
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
#!/bin/perl
|
||||
#
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
# -----------------------------------------------------------------
|
||||
#
|
||||
# explode.pl -- Unpack .jar files into bin, lib, include directories
|
||||
#
|
||||
# syntax: perl explode.pl
|
||||
#
|
||||
# Description:
|
||||
# explode.pl unpacks the .jar files created by the NSPR build
|
||||
# procedure.
|
||||
#
|
||||
# Suggested use: After copying the platform directories to
|
||||
# /s/b/c/nspr20/<release>. CD to /s/b/c/nspr20/<release> and
|
||||
# run explode.pl. This will unpack the jar files into bin, lib,
|
||||
# include directories.
|
||||
#
|
||||
# -----------------------------------------------------------------
|
||||
|
||||
@dirs = `ls -d *.OBJ*`;
|
||||
|
||||
foreach $dir (@dirs) {
|
||||
chop($dir);
|
||||
if (-l $dir) {
|
||||
print "Skipping symbolic link $dir\n";
|
||||
next;
|
||||
}
|
||||
print "Unzipping $dir/mdbinary.jar\n";
|
||||
system ("unzip", "-o", "$dir/mdbinary.jar",
|
||||
"-d", "$dir");
|
||||
system ("rm", "-rf", "$dir/META-INF");
|
||||
mkdir "$dir/include", 0755;
|
||||
print "Unzipping $dir/mdheader.jar\n";
|
||||
system ("unzip", "-o", "-aa",
|
||||
"$dir/mdheader.jar",
|
||||
"-d", "$dir/include");
|
||||
system ("rm", "-rf", "$dir/include/META-INF");
|
||||
}
|
||||
# --- end explode.pl ----------------------------------------------
|
||||
47
nsprpub/admin/makeTargetDirs.sh
Normal file
47
nsprpub/admin/makeTargetDirs.sh
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
# -----------------------------------------------------------------
|
||||
# makeTargetDirs.sh -- Create target directories for building NSPR
|
||||
#
|
||||
# syntax: makeTargetDirs.sh
|
||||
#
|
||||
# Description:
|
||||
# makeTargetDirs.sh creates a set of directories intended for use
|
||||
# with NSPR's autoconf based build system.
|
||||
#
|
||||
# The enumerated directories are the same as those built for NSPR
|
||||
# 4.1.1. Adjust as needed.
|
||||
#
|
||||
# -----------------------------------------------------------------
|
||||
|
||||
mkdir AIX4.3_64_DBG.OBJ
|
||||
mkdir AIX4.3_64_OPT.OBJ
|
||||
mkdir AIX4.3_DBG.OBJ
|
||||
mkdir AIX4.3_OPT.OBJ
|
||||
mkdir HP-UXB.11.00_64_DBG.OBJ
|
||||
mkdir HP-UXB.11.00_64_OPT.OBJ
|
||||
mkdir HP-UXB.11.00_DBG.OBJ
|
||||
mkdir HP-UXB.11.00_OPT.OBJ
|
||||
mkdir IRIX6.5_n32_PTH_DBG.OBJ
|
||||
mkdir IRIX6.5_n32_PTH_OPT.OBJ
|
||||
mkdir Linux2.2_x86_glibc_PTH_DBG.OBJ
|
||||
mkdir Linux2.2_x86_glibc_PTH_OPT.OBJ
|
||||
mkdir Linux2.4_x86_glibc_PTH_DBG.OBJ
|
||||
mkdir Linux2.4_x86_glibc_PTH_OPT.OBJ
|
||||
mkdir OSF1V4.0D_DBG.OBJ
|
||||
mkdir OSF1V4.0D_OPT.OBJ
|
||||
mkdir SunOS5.6_DBG.OBJ
|
||||
mkdir SunOS5.6_OPT.OBJ
|
||||
mkdir SunOS5.7_64_DBG.OBJ
|
||||
mkdir SunOS5.7_64_OPT.OBJ
|
||||
mkdir WIN954.0_DBG.OBJ
|
||||
mkdir WIN954.0_DBG.OBJD
|
||||
mkdir WIN954.0_OPT.OBJ
|
||||
mkdir WINNT4.0_DBG.OBJ
|
||||
mkdir WINNT4.0_DBG.OBJD
|
||||
mkdir WINNT4.0_OPT.OBJ
|
||||
# --- end makeTargetDirs.sh ---------------------------------------
|
||||
43
nsprpub/admin/symlinks.sh
Normal file
43
nsprpub/admin/symlinks.sh
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
# -----------------------------------------------------------------
|
||||
# symlinks.sh -- create links from NSPR builds
|
||||
#
|
||||
# syntax: symlinks.sh
|
||||
#
|
||||
# Description:
|
||||
# symlinks.sh creates some symbolic links for NSPR build targets
|
||||
# that are not actually build, but for which there are NSPR
|
||||
# binaries suitable for running on the intended target. ... got
|
||||
# that?
|
||||
#
|
||||
# Suggested use: After copying NSPR binaries to
|
||||
# /s/b/c/nspr20/<platform> run symlinks.sh to create the links
|
||||
# for all supported platforms.
|
||||
#
|
||||
# The symlinks in this script correspond to the NSPR 4.1.1
|
||||
# release. Adjust as necessary.
|
||||
#
|
||||
# -----------------------------------------------------------------
|
||||
|
||||
ln -s SunOS5.6_DBG.OBJ SunOS5.7_DBG.OBJ
|
||||
ln -s SunOS5.6_OPT.OBJ SunOS5.7_OPT.OBJ
|
||||
|
||||
ln -s SunOS5.6_DBG.OBJ SunOS5.8_DBG.OBJ
|
||||
ln -s SunOS5.6_OPT.OBJ SunOS5.8_OPT.OBJ
|
||||
|
||||
ln -s SunOS5.7_64_DBG.OBJ SunOS5.8_64_DBG.OBJ
|
||||
ln -s SunOS5.7_64_OPT.OBJ SunOS5.8_64_OPT.OBJ
|
||||
|
||||
ln -s OSF1V4.0D_DBG.OBJ OSF1V5.0_DBG.OBJ
|
||||
ln -s OSF1V4.0D_OPT.OBJ OSF1V5.0_OPT.OBJ
|
||||
|
||||
ln -s WINNT4.0_DBG.OBJ WINNT5.0_DBG.OBJ
|
||||
ln -s WINNT4.0_DBG.OBJD WINNT5.0_DBG.OBJD
|
||||
ln -s WINNT4.0_OPT.OBJ WINNT5.0_OPT.OBJ
|
||||
# --- end symlinks.sh ---------------------------------------------
|
||||
|
||||
179
nsprpub/automation/release/nspr-release-helper.py
Normal file
179
nsprpub/automation/release/nspr-release-helper.py
Normal file
|
|
@ -0,0 +1,179 @@
|
|||
#!/usr/bin/python
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
|
||||
import os
|
||||
import sys
|
||||
import datetime
|
||||
import shutil
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
from subprocess import check_call
|
||||
|
||||
prinit_h = "pr/include/prinit.h"
|
||||
f_conf = "configure"
|
||||
f_conf_in = "configure.in"
|
||||
|
||||
def check_call_noisy(cmd, *args, **kwargs):
|
||||
print "Executing command:", cmd
|
||||
check_call(cmd, *args, **kwargs)
|
||||
|
||||
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")
|
||||
|
||||
try:
|
||||
options, args = o.parse_args()
|
||||
action = args[0]
|
||||
except IndexError:
|
||||
o.print_help()
|
||||
sys.exit(2)
|
||||
|
||||
def exit_with_failure(what):
|
||||
print "failure: ", what
|
||||
sys.exit(2)
|
||||
|
||||
def check_files_exist():
|
||||
if (not os.path.exists(prinit_h)):
|
||||
exit_with_failure("cannot find expected header files, must run from inside NSPR hg directory")
|
||||
|
||||
def sed_inplace(sed_expression, filename):
|
||||
backup_file = filename + '.tmp'
|
||||
check_call_noisy(["sed", "-i.tmp", sed_expression, filename])
|
||||
os.remove(backup_file)
|
||||
|
||||
def toggle_beta_status(is_beta):
|
||||
check_files_exist()
|
||||
if (is_beta):
|
||||
print "adding Beta status to version numbers"
|
||||
sed_inplace('s/^\(#define *PR_VERSION *\"[0-9.]\+\)\" *$/\\1 Beta\"/', prinit_h)
|
||||
sed_inplace('s/^\(#define *PR_BETA *\)PR_FALSE *$/\\1PR_TRUE/', prinit_h)
|
||||
|
||||
else:
|
||||
print "removing Beta status from version numbers"
|
||||
sed_inplace('s/^\(#define *PR_VERSION *\"[0-9.]\+\) *Beta\" *$/\\1\"/', prinit_h)
|
||||
sed_inplace('s/^\(#define *PR_BETA *\)PR_TRUE *$/\\1PR_FALSE/', prinit_h)
|
||||
print "please run 'hg stat' and 'hg diff' to verify the files have been verified correctly"
|
||||
|
||||
def print_beta_versions():
|
||||
check_call_noisy(["egrep", "#define *PR_VERSION|#define *PR_BETA", prinit_h])
|
||||
|
||||
def remove_beta_status():
|
||||
print "--- removing beta flags. Existing versions were:"
|
||||
print_beta_versions()
|
||||
toggle_beta_status(False)
|
||||
print "--- finished modifications, new versions are:"
|
||||
print_beta_versions()
|
||||
|
||||
def set_beta_status():
|
||||
print "--- adding beta flags. Existing versions were:"
|
||||
print_beta_versions()
|
||||
toggle_beta_status(True)
|
||||
print "--- finished modifications, new versions are:"
|
||||
print_beta_versions()
|
||||
|
||||
def print_library_versions():
|
||||
check_files_exist()
|
||||
check_call_noisy(["egrep", "#define *PR_VERSION|#define PR_VMAJOR|#define *PR_VMINOR|#define *PR_VPATCH|#define *PR_BETA", prinit_h])
|
||||
|
||||
def ensure_arguments_after_action(how_many, usage):
|
||||
if (len(sys.argv) != (2+how_many)):
|
||||
exit_with_failure("incorrect number of arguments, expected parameters are:\n" + usage)
|
||||
|
||||
def set_major_versions(major):
|
||||
sed_inplace('s/^\(#define *PR_VMAJOR *\).*$/\\1' + major + '/', prinit_h)
|
||||
sed_inplace('s/^MOD_MAJOR_VERSION=.*$/MOD_MAJOR_VERSION=' + major + '/', f_conf)
|
||||
sed_inplace('s/^MOD_MAJOR_VERSION=.*$/MOD_MAJOR_VERSION=' + major + '/', f_conf_in)
|
||||
|
||||
def set_minor_versions(minor):
|
||||
sed_inplace('s/^\(#define *PR_VMINOR *\).*$/\\1' + minor + '/', prinit_h)
|
||||
sed_inplace('s/^MOD_MINOR_VERSION=.*$/MOD_MINOR_VERSION=' + minor + '/', f_conf)
|
||||
sed_inplace('s/^MOD_MINOR_VERSION=.*$/MOD_MINOR_VERSION=' + minor + '/', f_conf_in)
|
||||
|
||||
def set_patch_versions(patch):
|
||||
sed_inplace('s/^\(#define *PR_VPATCH *\).*$/\\1' + patch + '/', prinit_h)
|
||||
sed_inplace('s/^MOD_PATCH_VERSION=.*$/MOD_PATCH_VERSION=' + patch + '/', f_conf)
|
||||
sed_inplace('s/^MOD_PATCH_VERSION=.*$/MOD_PATCH_VERSION=' + patch + '/', f_conf_in)
|
||||
|
||||
def set_full_lib_versions(version):
|
||||
sed_inplace('s/^\(#define *PR_VERSION *\"\)\([0-9.]\+\)\(.*\)$/\\1' + version + '\\3/', prinit_h)
|
||||
|
||||
def set_all_lib_versions(version, major, minor, patch):
|
||||
set_full_lib_versions(version)
|
||||
set_major_versions(major)
|
||||
set_minor_versions(minor)
|
||||
set_patch_versions(patch)
|
||||
print
|
||||
print "==========================="
|
||||
print "======== ATTENTION ========"
|
||||
print
|
||||
print "You *MUST* manually edit file pr/tests/vercheck.c"
|
||||
print
|
||||
print "Edit two arrays, named compatible_version and incompatible_version"
|
||||
print "according to the new version you're adding."
|
||||
print
|
||||
print "======== ATTENTION ========"
|
||||
print "==========================="
|
||||
|
||||
def set_version_to_minor_release():
|
||||
ensure_arguments_after_action(2, "major_version minor_version")
|
||||
major = args[1].strip()
|
||||
minor = args[2].strip()
|
||||
version = major + '.' + minor
|
||||
patch = "0"
|
||||
set_all_lib_versions(version, major, minor, patch)
|
||||
|
||||
def set_version_to_patch_release():
|
||||
ensure_arguments_after_action(3, "major_version minor_version patch_release")
|
||||
major = args[1].strip()
|
||||
minor = args[2].strip()
|
||||
patch = args[3].strip()
|
||||
version = major + '.' + minor + '.' + patch
|
||||
set_all_lib_versions(version, major, minor, patch)
|
||||
|
||||
def create_nspr_release_archive():
|
||||
ensure_arguments_after_action(2, "nspr_release_version nspr_hg_release_tag")
|
||||
nsprrel = args[1].strip() #e.g. 4.10.9
|
||||
nsprreltag = args[2].strip() #e.g. NSPR_4_10_9_RTM
|
||||
|
||||
nspr_tar = "nspr-" + nsprrel + ".tar.gz"
|
||||
nspr_stagedir="../stage/v" + nsprrel + "/src"
|
||||
if (os.path.exists(nspr_stagedir)):
|
||||
exit_with_failure("nspr stage directory already exists: " + nspr_stagedir)
|
||||
|
||||
check_call_noisy(["mkdir", "-p", nspr_stagedir])
|
||||
check_call_noisy(["hg", "archive", "-r", nsprreltag, "--prefix=nspr-" + nsprrel + "/nspr",
|
||||
"../stage/v" + nsprrel + "/src/" + nspr_tar, "-X", ".hgtags"])
|
||||
print "changing to directory " + nspr_stagedir
|
||||
os.chdir(nspr_stagedir)
|
||||
|
||||
check_call("sha1sum " + nspr_tar + " > SHA1SUMS", shell=True)
|
||||
check_call("sha256sum " + nspr_tar + " > SHA256SUMS", shell=True)
|
||||
print "created directory " + nspr_stagedir + " with files:"
|
||||
check_call_noisy(["ls", "-l"])
|
||||
|
||||
if action in ('remove_beta'):
|
||||
remove_beta_status()
|
||||
|
||||
elif action in ('set_beta'):
|
||||
set_beta_status()
|
||||
|
||||
elif action in ('print_library_versions'):
|
||||
print_library_versions()
|
||||
|
||||
# x.y version number - 2 parameters
|
||||
elif action in ('set_version_to_minor_release'):
|
||||
set_version_to_minor_release()
|
||||
|
||||
# x.y.z version number - 3 parameters
|
||||
elif action in ('set_version_to_patch_release'):
|
||||
set_version_to_patch_release()
|
||||
|
||||
elif action in ('create_nspr_release_archive'):
|
||||
create_nspr_release_archive()
|
||||
|
||||
else:
|
||||
o.print_help()
|
||||
sys.exit(2)
|
||||
|
||||
sys.exit(0)
|
||||
5
nsprpub/build/autoconf/README
Normal file
5
nsprpub/build/autoconf/README
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
The config.guess and config.sub scripts were downloaded from
|
||||
http://git.savannah.gnu.org/cgit/config.git/tree/config.guess?id=6947a35648e577c2e3a12d5c88d488c6ea94e1c0
|
||||
http://git.savannah.gnu.org/cgit/config.git/tree/config.sub?id=6947a35648e577c2e3a12d5c88d488c6ea94e1c0
|
||||
|
||||
Our private patches are in the patches/ directory.
|
||||
1420
nsprpub/build/autoconf/config.guess
vendored
Normal file
1420
nsprpub/build/autoconf/config.guess
vendored
Normal file
File diff suppressed because it is too large
Load diff
1795
nsprpub/build/autoconf/config.sub
vendored
Normal file
1795
nsprpub/build/autoconf/config.sub
vendored
Normal file
File diff suppressed because it is too large
Load diff
123
nsprpub/build/autoconf/install-sh
Normal file
123
nsprpub/build/autoconf/install-sh
Normal file
|
|
@ -0,0 +1,123 @@
|
|||
#!/bin/sh
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
|
||||
#
|
||||
# install - install a program, script, or datafile
|
||||
# This comes from X11R5; it is not part of GNU.
|
||||
#
|
||||
# $XConsortium: install.sh,v 1.2 89/12/18 14:47:22 jim Exp $
|
||||
#
|
||||
# This script is compatible with the BSD install script, but was written
|
||||
# from scratch.
|
||||
#
|
||||
|
||||
|
||||
# set DOITPROG to echo to test this script
|
||||
|
||||
# Don't use :- since 4.3BSD and earlier shells don't like it.
|
||||
doit="${DOITPROG-}"
|
||||
|
||||
|
||||
# put in absolute paths if you don't have them in your path; or use env. vars.
|
||||
|
||||
mvprog="${MVPROG-mv}"
|
||||
cpprog="${CPPROG-cp}"
|
||||
chmodprog="${CHMODPROG-chmod}"
|
||||
chownprog="${CHOWNPROG-chown}"
|
||||
chgrpprog="${CHGRPPROG-chgrp}"
|
||||
stripprog="${STRIPPROG-strip}"
|
||||
rmprog="${RMPROG-rm}"
|
||||
|
||||
instcmd="$mvprog"
|
||||
chmodcmd=""
|
||||
chowncmd=""
|
||||
chgrpcmd=""
|
||||
stripcmd=""
|
||||
rmcmd="$rmprog -f"
|
||||
mvcmd="$mvprog"
|
||||
src=""
|
||||
dst=""
|
||||
|
||||
while [ x"$1" != x ]; do
|
||||
case $1 in
|
||||
-c) instcmd="$cpprog"
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-m) chmodcmd="$chmodprog $2"
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-o) chowncmd="$chownprog $2"
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-g) chgrpcmd="$chgrpprog $2"
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-s) stripcmd="$stripprog"
|
||||
shift
|
||||
continue;;
|
||||
|
||||
*) if [ x"$src" = x ]
|
||||
then
|
||||
src=$1
|
||||
else
|
||||
dst=$1
|
||||
fi
|
||||
shift
|
||||
continue;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ x"$src" = x ]
|
||||
then
|
||||
echo "install: no input file specified"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ x"$dst" = x ]
|
||||
then
|
||||
echo "install: no destination specified"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
# If destination is a directory, append the input filename; if your system
|
||||
# does not like double slashes in filenames, you may need to add some logic
|
||||
|
||||
if [ -d $dst ]
|
||||
then
|
||||
dst="$dst"/`basename $src`
|
||||
fi
|
||||
|
||||
# Make a temp file name in the proper directory.
|
||||
|
||||
dstdir=`dirname $dst`
|
||||
dsttmp=$dstdir/#inst.$$#
|
||||
|
||||
# Move or copy the file name to the temp name
|
||||
|
||||
$doit $instcmd $src $dsttmp
|
||||
|
||||
# and set any options; do chmod last to preserve setuid bits
|
||||
|
||||
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; fi
|
||||
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; fi
|
||||
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; fi
|
||||
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; fi
|
||||
|
||||
# Now rename the file to the real destination.
|
||||
|
||||
$doit $rmcmd $dst
|
||||
$doit $mvcmd $dsttmp $dst
|
||||
|
||||
|
||||
exit 0
|
||||
51
nsprpub/build/autoconf/patches/config.sub.patch
Normal file
51
nsprpub/build/autoconf/patches/config.sub.patch
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
--- config.sub.orig 2014-03-09 18:34:03 -0700
|
||||
+++ config.sub 2014-03-14 19:49:48 -0700
|
||||
@@ -115,7 +115,7 @@
|
||||
# Here we must recognize all the valid KERNEL-OS combinations.
|
||||
maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
|
||||
case $maybe_os in
|
||||
- nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \
|
||||
+ nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | \
|
||||
linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \
|
||||
knetbsd*-gnu* | netbsd*-gnu* | \
|
||||
kopensolaris*-gnu* | \
|
||||
@@ -123,10 +123,6 @@
|
||||
os=-$maybe_os
|
||||
basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
|
||||
;;
|
||||
- android-linux)
|
||||
- os=-linux-android
|
||||
- basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown
|
||||
- ;;
|
||||
*)
|
||||
basic_machine=`echo $1 | sed 's/-[^-]*$//'`
|
||||
if [ $basic_machine != $1 ]
|
||||
@@ -1367,7 +1363,7 @@
|
||||
| -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
|
||||
| -chorusos* | -chorusrdb* | -cegcc* \
|
||||
| -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
|
||||
- | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \
|
||||
+ | -mingw32* | -mingw64* | -linux-gnu* \
|
||||
| -linux-newlib* | -linux-musl* | -linux-uclibc* \
|
||||
| -uxpv* | -beos* | -mpeix* | -udk* \
|
||||
| -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
|
||||
@@ -1508,6 +1504,9 @@
|
||||
;;
|
||||
-nacl*)
|
||||
;;
|
||||
+ -android*)
|
||||
+ os=-android
|
||||
+ ;;
|
||||
-none)
|
||||
;;
|
||||
*)
|
||||
@@ -1777,6 +1776,9 @@
|
||||
-vos*)
|
||||
vendor=stratus
|
||||
;;
|
||||
+ *-android*|*-linuxandroid*)
|
||||
+ vendor=linux-
|
||||
+ ;;
|
||||
esac
|
||||
basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"`
|
||||
;;
|
||||
79
nsprpub/build/cygwin-wrapper
Normal file
79
nsprpub/build/cygwin-wrapper
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
#!/bin/sh
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
#
|
||||
# Stupid wrapper to avoid win32 dospath/cygdrive issues
|
||||
# Try not to spawn programs from within this file. If the stuff in here looks royally
|
||||
# confusing, see bug: http://bugzilla.mozilla.org/show_bug.cgi?id=206643
|
||||
# and look at the older versions of this file that are easier to read, but
|
||||
# do basically the same thing
|
||||
#
|
||||
|
||||
prog=$1
|
||||
shift
|
||||
if test -z "$prog"; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# If $CYGDRIVE_MOUNT was not set in configure, give $mountpoint the results of mount -p
|
||||
mountpoint=$CYGDRIVE_MOUNT
|
||||
if test -z "$mountpoint"; then
|
||||
mountpoint=`mount -p`
|
||||
if test -z "$mountpoint"; then
|
||||
print "Cannot determine cygwin mount points. Exiting"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# Delete everything but "/cygdrive" (or other mountpoint) from mount=`mount -p`
|
||||
mountpoint=${mountpoint#*/}
|
||||
mountpoint=/${mountpoint%%[!A-Za-z0-9_]*}
|
||||
mountpoint=${mountpoint%/}
|
||||
|
||||
args=""
|
||||
up=""
|
||||
if test "${prog}" = "-up"; then
|
||||
up=1
|
||||
prog=${1}
|
||||
shift
|
||||
fi
|
||||
|
||||
process=1
|
||||
|
||||
# Convert the mountpoint in parameters to Win32 filenames
|
||||
# For instance: /cygdrive/c/foo -> c:/foo
|
||||
for i in "${@}"
|
||||
do
|
||||
if test "${i}" = "-wrap"; then
|
||||
process=1
|
||||
else
|
||||
if test "${i}" = "-nowrap"; then
|
||||
process=
|
||||
else
|
||||
if test -n "${process}"; then
|
||||
if test -n "${up}"; then
|
||||
pathname=${i#-I[a-zA-Z]:/}
|
||||
if ! test "${pathname}" = "${i}"; then
|
||||
no_i=${i#-I}
|
||||
driveletter=${no_i%%:*}
|
||||
i=-I${mountpoint}/${driveletter}/${pathname}
|
||||
fi
|
||||
else
|
||||
eval 'leader=${i%%'${mountpoint}'/[a-zA-Z]/*}'
|
||||
if ! test "${leader}" = "${i}"; then
|
||||
eval 'pathname=${i#'${leader}${mountpoint}'/[a-zA-Z]/}'
|
||||
eval 'no_mountpoint=${i#'${leader}${mountpoint}'/}'
|
||||
driveletter=${no_mountpoint%%/*}
|
||||
i=${leader}${driveletter}:/${pathname}
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
args="${args} ${i}"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
exec $prog $args
|
||||
44
nsprpub/build/win32/pgomerge.py
Normal file
44
nsprpub/build/win32/pgomerge.py
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
#!/usr/bin/python
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
# Usage: pgomerge.py <binary basename> <dist/bin>
|
||||
# Gathers .pgc files from dist/bin and merges them into
|
||||
# $PWD/$basename.pgd using pgomgr, then deletes them.
|
||||
# No errors if any of these files don't exist.
|
||||
|
||||
import sys, os, os.path, subprocess
|
||||
if not sys.platform == "win32":
|
||||
raise Exception("This script was only meant for Windows.")
|
||||
|
||||
def MergePGOFiles(basename, pgddir, pgcdir):
|
||||
"""Merge pgc files produced from an instrumented binary
|
||||
into the pgd file for the second pass of profile-guided optimization
|
||||
with MSVC. |basename| is the name of the DLL or EXE without the
|
||||
extension. |pgddir| is the path that contains <basename>.pgd
|
||||
(should be the objdir it was built in). |pgcdir| is the path
|
||||
containing basename!N.pgc files, which is probably dist/bin.
|
||||
Calls pgomgr to merge each pgc file into the pgd, then deletes
|
||||
the pgc files."""
|
||||
if not os.path.isdir(pgddir) or not os.path.isdir(pgcdir):
|
||||
return
|
||||
pgdfile = os.path.abspath(os.path.join(pgddir, basename + ".pgd"))
|
||||
if not os.path.isfile(pgdfile):
|
||||
return
|
||||
for file in os.listdir(pgcdir):
|
||||
if file.startswith(basename+"!") and file.endswith(".pgc"):
|
||||
try:
|
||||
pgcfile = os.path.normpath(os.path.join(pgcdir, file))
|
||||
subprocess.call(['pgomgr', '-merge',
|
||||
pgcfile,
|
||||
pgdfile])
|
||||
os.remove(pgcfile)
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
if __name__ == '__main__':
|
||||
if len(sys.argv) != 3:
|
||||
print >>sys.stderr, "Usage: pgomerge.py <binary basename> <dist/bin>"
|
||||
sys.exit(1)
|
||||
MergePGOFiles(sys.argv[1], os.getcwd(), sys.argv[2])
|
||||
11
nsprpub/config/.cvsignore
Normal file
11
nsprpub/config/.cvsignore
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
nfspwd
|
||||
revdepth
|
||||
my_config.mk
|
||||
my_overrides.mk
|
||||
autoconf.mk
|
||||
nsprincl.mk
|
||||
nsprincl.sh
|
||||
now
|
||||
Makefile
|
||||
nsinstall
|
||||
nspr-config
|
||||
124
nsprpub/config/Makefile.in
Normal file
124
nsprpub/config/Makefile.in
Normal file
|
|
@ -0,0 +1,124 @@
|
|||
#! gmake
|
||||
#
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
MOD_DEPTH = ..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(MOD_DEPTH)/config/autoconf.mk
|
||||
|
||||
# Indicate that this directory builds build tools.
|
||||
INTERNAL_TOOLS = 1
|
||||
|
||||
# For sanity's sake, we compile nsinstall without the wrapped system
|
||||
# headers, so that we can use it to set up the wrapped system headers.
|
||||
VISIBILITY_FLAGS =
|
||||
|
||||
# autoconf.mk must be deleted last (from the top-level directory)
|
||||
# because it is included by every makefile.
|
||||
DIST_GARBAGE = nsprincl.mk nsprincl.sh nspr-config nspr.pc
|
||||
|
||||
RELEASE_BINS = nspr-config
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
CSRCS = now.c
|
||||
|
||||
# This version hasn't been ported for us; the one in mozilla/config has
|
||||
ifneq ($(OS_ARCH),OS2)
|
||||
CSRCS += nsinstall.c
|
||||
|
||||
PLSRCS = nfspwd.pl
|
||||
endif
|
||||
|
||||
ifeq (,$(CROSS_COMPILE)$(filter-out WINNT OS2,$(OS_ARCH)))
|
||||
PROG_SUFFIX = .exe
|
||||
else
|
||||
PROG_SUFFIX =
|
||||
endif
|
||||
|
||||
# Temporary workaround to disable the generation of
|
||||
# library build time because now.c uses the 'long long'
|
||||
# data type that's not available on some platforms.
|
||||
ifeq (,$(filter-out QNX SCOOS UNIXWARE,$(OS_ARCH)))
|
||||
DEFINES += -DOMIT_LIB_BUILD_TIME
|
||||
endif
|
||||
|
||||
ifeq ($(OS_ARCH), IRIX)
|
||||
ifeq ($(basename $(OS_RELEASE)),6)
|
||||
ifndef NS_USE_GCC
|
||||
ifeq ($(USE_N32),1)
|
||||
XLDOPTS += -n32 -Wl,-woff,85
|
||||
else
|
||||
ifeq ($(USE_64),1)
|
||||
XLDOPTS += -64
|
||||
else
|
||||
XLDOPTS += -32
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(OS_ARCH), HP-UX)
|
||||
ifeq ($(USE_64),1)
|
||||
XLDOPTS += +DD64
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(OS_ARCH), OS2)
|
||||
XCFLAGS = $(OS_CFLAGS)
|
||||
endif
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
PROGS = $(OBJDIR)/now$(PROG_SUFFIX)
|
||||
|
||||
ifeq (,$(CROSS_COMPILE)$(filter-out OS2 WINNT,$(OS_ARCH)))
|
||||
TARGETS = $(PROGS)
|
||||
else
|
||||
ifeq (,$(filter-out SYMBIAN WINCE,$(OS_ARCH)))
|
||||
TARGETS = $(PROGS)
|
||||
else
|
||||
PROGS += $(OBJDIR)/nsinstall$(PROG_SUFFIX)
|
||||
TARGETS = $(PROGS) $(PLSRCS:.pl=)
|
||||
endif
|
||||
endif
|
||||
|
||||
OUTOPTION = -o # end of the line
|
||||
ifeq (,$(filter-out WINNT WIN95 WINCE,$(OS_TARGET)))
|
||||
ifndef NS_USE_GCC
|
||||
OUTOPTION = -Fe
|
||||
endif
|
||||
endif
|
||||
|
||||
# Redefine MAKE_OBJDIR for just this directory
|
||||
define MAKE_OBJDIR
|
||||
if test ! -d $(@D); then rm -rf $(@D); mkdir $(@D); else true; fi
|
||||
endef
|
||||
|
||||
export:: $(TARGETS)
|
||||
rm -f $(dist_bindir)/nspr-config
|
||||
|
||||
ifdef WRAP_SYSTEM_INCLUDES
|
||||
export::
|
||||
if test ! -d system_wrappers; then mkdir system_wrappers; fi
|
||||
$(PERL) $(srcdir)/make-system-wrappers.pl system_wrappers < $(srcdir)/system-headers
|
||||
$(INSTALL) system_wrappers $(dist_includedir)
|
||||
endif
|
||||
|
||||
$(OBJDIR)/%$(PROG_SUFFIX): $(OBJDIR)/%.$(OBJ_SUFFIX)
|
||||
@$(MAKE_OBJDIR)
|
||||
$(CC) $(XCFLAGS) $< $(LDFLAGS) $(XLDOPTS) $(OUTOPTION)$@
|
||||
|
||||
install:: nspr.m4
|
||||
$(NSINSTALL) -D $(DESTDIR)$(datadir)/aclocal
|
||||
$(NSINSTALL) -t -m 0644 $< $(DESTDIR)$(datadir)/aclocal
|
||||
|
||||
install:: nspr.pc
|
||||
$(NSINSTALL) -D $(DESTDIR)$(libdir)/pkgconfig
|
||||
$(NSINSTALL) -t -m 0644 $< $(DESTDIR)$(libdir)/pkgconfig
|
||||
148
nsprpub/config/autoconf.mk.in
Normal file
148
nsprpub/config/autoconf.mk.in
Normal file
|
|
@ -0,0 +1,148 @@
|
|||
# -*- Mode: Makefile -*-
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
|
||||
INCLUDED_AUTOCONF_MK = 1
|
||||
USE_AUTOCONF = 1
|
||||
@SHELL_OVERRIDE@
|
||||
MOZILLA_CLIENT = @MOZILLA_CLIENT@
|
||||
|
||||
prefix = @prefix@
|
||||
exec_prefix = @exec_prefix@
|
||||
bindir = @bindir@
|
||||
includedir = @includedir@
|
||||
libdir = @libdir@
|
||||
datarootdir = @datarootdir@
|
||||
datadir = @datadir@
|
||||
|
||||
dist_prefix = @dist_prefix@
|
||||
dist_bindir = @dist_bindir@
|
||||
dist_includedir = @dist_includedir@
|
||||
dist_libdir = @dist_libdir@
|
||||
|
||||
DIST = $(dist_prefix)
|
||||
|
||||
RELEASE_OBJDIR_NAME = @RELEASE_OBJDIR_NAME@
|
||||
OBJDIR_NAME = @OBJDIR_NAME@
|
||||
OBJDIR = @OBJDIR@
|
||||
# We do magic with OBJ_SUFFIX in config.mk, the following ensures we don't
|
||||
# manually use it before config.mk inclusion
|
||||
OBJ_SUFFIX = $(error config/config.mk needs to be included before using OBJ_SUFFIX)
|
||||
_OBJ_SUFFIX = @OBJ_SUFFIX@
|
||||
LIB_SUFFIX = @LIB_SUFFIX@
|
||||
DLL_SUFFIX = @DLL_SUFFIX@
|
||||
ASM_SUFFIX = @ASM_SUFFIX@
|
||||
MOD_NAME = @NSPR_MODNAME@
|
||||
|
||||
MOD_MAJOR_VERSION = @MOD_MAJOR_VERSION@
|
||||
MOD_MINOR_VERSION = @MOD_MINOR_VERSION@
|
||||
MOD_PATCH_VERSION = @MOD_PATCH_VERSION@
|
||||
|
||||
LIBNSPR = @LIBNSPR@
|
||||
LIBPLC = @LIBPLC@
|
||||
|
||||
CROSS_COMPILE = @CROSS_COMPILE@
|
||||
MOZ_OPTIMIZE = @MOZ_OPTIMIZE@
|
||||
MOZ_DEBUG = @MOZ_DEBUG@
|
||||
MOZ_DEBUG_SYMBOLS = @MOZ_DEBUG_SYMBOLS@
|
||||
|
||||
USE_CPLUS = @USE_CPLUS@
|
||||
USE_IPV6 = @USE_IPV6@
|
||||
USE_N32 = @USE_N32@
|
||||
USE_X32 = @USE_X32@
|
||||
USE_64 = @USE_64@
|
||||
ENABLE_STRIP = @ENABLE_STRIP@
|
||||
|
||||
USE_PTHREADS = @USE_PTHREADS@
|
||||
USE_BTHREADS = @USE_BTHREADS@
|
||||
PTHREADS_USER = @USE_USER_PTHREADS@
|
||||
CLASSIC_NSPR = @USE_NSPR_THREADS@
|
||||
|
||||
AS = @AS@
|
||||
ASFLAGS = @ASFLAGS@
|
||||
CC = @CC@
|
||||
CCC = @CXX@
|
||||
NS_USE_GCC = @GNU_CC@
|
||||
GCC_USE_GNU_LD = @GCC_USE_GNU_LD@
|
||||
MSC_VER = @MSC_VER@
|
||||
AR = @AR@
|
||||
AR_FLAGS = @AR_FLAGS@
|
||||
LD = @LD@
|
||||
RANLIB = @RANLIB@
|
||||
PERL = @PERL@
|
||||
RC = @RC@
|
||||
RCFLAGS = @RCFLAGS@
|
||||
STRIP = @STRIP@
|
||||
NSINSTALL = @NSINSTALL@
|
||||
FILTER = @FILTER@
|
||||
IMPLIB = @IMPLIB@
|
||||
CYGWIN_WRAPPER = @CYGWIN_WRAPPER@
|
||||
MT = @MT@
|
||||
|
||||
OS_CPPFLAGS = @CPPFLAGS@
|
||||
OS_CFLAGS = $(OS_CPPFLAGS) @CFLAGS@ $(DSO_CFLAGS)
|
||||
OS_CXXFLAGS = $(OS_CPPFLAGS) @CXXFLAGS@ $(DSO_CFLAGS)
|
||||
OS_LIBS = @OS_LIBS@
|
||||
OS_LDFLAGS = @LDFLAGS@
|
||||
OS_DLLFLAGS = @OS_DLLFLAGS@
|
||||
DLLFLAGS = @DLLFLAGS@
|
||||
EXEFLAGS = @EXEFLAGS@
|
||||
OPTIMIZER = @OPTIMIZER@
|
||||
|
||||
PROFILE_GEN_CFLAGS = @PROFILE_GEN_CFLAGS@
|
||||
PROFILE_GEN_LDFLAGS = @PROFILE_GEN_LDFLAGS@
|
||||
PROFILE_USE_CFLAGS = @PROFILE_USE_CFLAGS@
|
||||
PROFILE_USE_LDFLAGS = @PROFILE_USE_LDFLAGS@
|
||||
|
||||
MKSHLIB = @MKSHLIB@
|
||||
WRAP_LDFLAGS = @WRAP_LDFLAGS@
|
||||
DSO_CFLAGS = @DSO_CFLAGS@
|
||||
DSO_LDOPTS = @DSO_LDOPTS@
|
||||
|
||||
RESOLVE_LINK_SYMBOLS = @RESOLVE_LINK_SYMBOLS@
|
||||
|
||||
HOST_CC = @HOST_CC@
|
||||
HOST_CFLAGS = @HOST_CFLAGS@
|
||||
HOST_LDFLAGS = @HOST_LDFLAGS@
|
||||
|
||||
DEFINES = @DEFINES@ @DEFS@
|
||||
|
||||
MDCPUCFG_H = @MDCPUCFG_H@
|
||||
PR_MD_CSRCS = @PR_MD_CSRCS@
|
||||
PR_MD_ASFILES = @PR_MD_ASFILES@
|
||||
PR_MD_ARCH_DIR = @PR_MD_ARCH_DIR@
|
||||
CPU_ARCH = @CPU_ARCH@
|
||||
|
||||
OS_TARGET = @OS_TARGET@
|
||||
OS_ARCH = @OS_ARCH@
|
||||
OS_RELEASE = @OS_RELEASE@
|
||||
OS_TEST = @OS_TEST@
|
||||
|
||||
NOSUCHFILE = @NOSUCHFILE@
|
||||
AIX_LINK_OPTS = @AIX_LINK_OPTS@
|
||||
MOZ_OBJFORMAT = @MOZ_OBJFORMAT@
|
||||
ULTRASPARC_LIBRARY = @ULTRASPARC_LIBRARY@
|
||||
|
||||
OBJECT_MODE = @OBJECT_MODE@
|
||||
ifdef OBJECT_MODE
|
||||
export OBJECT_MODE
|
||||
endif
|
||||
|
||||
VISIBILITY_FLAGS = @VISIBILITY_FLAGS@
|
||||
WRAP_SYSTEM_INCLUDES = @WRAP_SYSTEM_INCLUDES@
|
||||
|
||||
MACOSX_DEPLOYMENT_TARGET = @MACOSX_DEPLOYMENT_TARGET@
|
||||
ifdef MACOSX_DEPLOYMENT_TARGET
|
||||
export MACOSX_DEPLOYMENT_TARGET
|
||||
endif
|
||||
|
||||
MACOS_SDK_DIR = @MACOS_SDK_DIR@
|
||||
|
||||
SYMBIAN_SDK_DIR = @SYMBIAN_SDK_DIR@
|
||||
|
||||
NEXT_ROOT = @NEXT_ROOT@
|
||||
ifdef NEXT_ROOT
|
||||
export NEXT_ROOT
|
||||
endif
|
||||
169
nsprpub/config/config.mk
Normal file
169
nsprpub/config/config.mk
Normal file
|
|
@ -0,0 +1,169 @@
|
|||
#! gmake
|
||||
#
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
# Configuration information for building in the NSPR source module
|
||||
|
||||
# Define an include-at-most-once-flag
|
||||
NSPR_CONFIG_MK = 1
|
||||
|
||||
#
|
||||
# The variable definitions in this file are inputs to NSPR's
|
||||
# build system. This file, if present, is included at the
|
||||
# beginning of config.mk.
|
||||
#
|
||||
# For example:
|
||||
#
|
||||
# MOZ_OPTIMIZE=1
|
||||
# USE_PTHREADS=1
|
||||
# NS_USE_GCC=
|
||||
#
|
||||
ifndef topsrcdir
|
||||
topsrcdir=$(MOD_DEPTH)
|
||||
endif
|
||||
|
||||
ifndef srcdir
|
||||
srcdir=.
|
||||
endif
|
||||
|
||||
NFSPWD = $(MOD_DEPTH)/config/nfspwd
|
||||
|
||||
CFLAGS = $(VISIBILITY_FLAGS) $(CC_ONLY_FLAGS) $(OPTIMIZER)\
|
||||
$(OS_CFLAGS) $(XP_DEFINE) $(DEFINES) $(INCLUDES) $(XCFLAGS)
|
||||
CCCFLAGS = $(VISIBILITY_FLAGS) $(CCC_ONLY_FLAGS) $(OPTIMIZER)\
|
||||
$(OS_CFLAGS) $(XP_DEFINE) $(DEFINES) $(INCLUDES) $(XCFLAGS)
|
||||
# For purify
|
||||
NOMD_CFLAGS = $(CC_ONLY_FLAGS) $(OPTIMIZER) $(NOMD_OS_CFLAGS)\
|
||||
$(XP_DEFINE) $(DEFINES) $(INCLUDES) $(XCFLAGS)
|
||||
NOMD_CCFLAGS = $(CCC_ONLY_FLAGS) $(OPTIMIZER) $(NOMD_OS_CFLAGS)\
|
||||
$(XP_DEFINE) $(DEFINES) $(INCLUDES) $(XCFLAGS)
|
||||
|
||||
LDFLAGS = $(OS_LDFLAGS)
|
||||
|
||||
# Enable profile-guided optimization
|
||||
ifndef NO_PROFILE_GUIDED_OPTIMIZE
|
||||
ifdef MOZ_PROFILE_GENERATE
|
||||
CFLAGS += $(PROFILE_GEN_CFLAGS)
|
||||
LDFLAGS += $(PROFILE_GEN_LDFLAGS)
|
||||
DLLFLAGS += $(PROFILE_GEN_LDFLAGS)
|
||||
ifeq (WINNT,$(OS_ARCH))
|
||||
AR_FLAGS += -LTCG
|
||||
endif
|
||||
endif # MOZ_PROFILE_GENERATE
|
||||
|
||||
ifdef MOZ_PROFILE_USE
|
||||
CFLAGS += $(PROFILE_USE_CFLAGS)
|
||||
LDFLAGS += $(PROFILE_USE_LDFLAGS)
|
||||
DLLFLAGS += $(PROFILE_USE_LDFLAGS)
|
||||
ifeq (WINNT,$(OS_ARCH))
|
||||
AR_FLAGS += -LTCG
|
||||
endif
|
||||
endif # MOZ_PROFILE_USE
|
||||
endif # NO_PROFILE_GUIDED_OPTIMIZE
|
||||
|
||||
define MAKE_OBJDIR
|
||||
if test ! -d $(@D); then rm -rf $(@D); $(NSINSTALL) -D $(@D); fi
|
||||
endef
|
||||
|
||||
LINK_DLL = $(LD) $(OS_DLLFLAGS) $(DLLFLAGS)
|
||||
|
||||
ifeq ($(OS_ARCH),Darwin)
|
||||
PWD := $(shell pwd)
|
||||
endif
|
||||
|
||||
ifeq (,$(CROSS_COMPILE)$(filter-out WINNT OS2, $(OS_ARCH)))
|
||||
INSTALL = $(NSINSTALL)
|
||||
else
|
||||
ifeq ($(NSDISTMODE),copy)
|
||||
# copy files, but preserve source mtime
|
||||
INSTALL = $(NSINSTALL) -t
|
||||
else
|
||||
ifeq ($(NSDISTMODE),absolute_symlink)
|
||||
# install using absolute symbolic links
|
||||
ifeq ($(OS_ARCH),Darwin)
|
||||
INSTALL = $(NSINSTALL) -L $(PWD)
|
||||
else
|
||||
INSTALL = $(NSINSTALL) -L `$(NFSPWD)`
|
||||
endif
|
||||
else
|
||||
# install using relative symbolic links
|
||||
INSTALL = $(NSINSTALL) -R
|
||||
endif
|
||||
endif
|
||||
endif # (WINNT || OS2) && !CROSS_COMPILE
|
||||
|
||||
DEPENDENCIES = $(OBJDIR)/.md
|
||||
|
||||
ifdef BUILD_DEBUG_GC
|
||||
DEFINES += -DDEBUG_GC
|
||||
endif
|
||||
|
||||
GARBAGE += $(DEPENDENCIES) core $(wildcard core.[0-9]*)
|
||||
|
||||
DIST_GARBAGE += Makefile
|
||||
|
||||
####################################################################
|
||||
#
|
||||
# The NSPR-specific configuration
|
||||
#
|
||||
####################################################################
|
||||
|
||||
DEFINES += -DFORCE_PR_LOG
|
||||
|
||||
ifeq ($(_PR_NO_CLOCK_TIMER),1)
|
||||
DEFINES += -D_PR_NO_CLOCK_TIMER
|
||||
endif
|
||||
|
||||
ifeq ($(USE_PTHREADS), 1)
|
||||
DEFINES += -D_PR_PTHREADS -UHAVE_CVAR_BUILT_ON_SEM
|
||||
endif
|
||||
|
||||
ifeq ($(PTHREADS_USER), 1)
|
||||
DEFINES += -DPTHREADS_USER -UHAVE_CVAR_BUILT_ON_SEM
|
||||
endif
|
||||
|
||||
ifeq ($(USE_IPV6),1)
|
||||
DEFINES += -D_PR_INET6
|
||||
endif
|
||||
|
||||
ifeq ($(MOZ_UNICODE),1)
|
||||
DEFINES += -DMOZ_UNICODE
|
||||
endif
|
||||
|
||||
####################################################################
|
||||
#
|
||||
# Configuration for the release process
|
||||
#
|
||||
####################################################################
|
||||
|
||||
MDIST = /m/dist
|
||||
ifeq ($(OS_ARCH),WINNT)
|
||||
MDIST = //helium/dist
|
||||
MDIST_DOS = $(subst /,\\,$(MDIST))
|
||||
endif
|
||||
|
||||
# RELEASE_DIR is ns/dist/<module name>
|
||||
|
||||
RELEASE_DIR = $(MOD_DEPTH)/dist/release/$(MOD_NAME)
|
||||
|
||||
RELEASE_INCLUDE_DIR = $(RELEASE_DIR)/$(BUILD_NUMBER)/$(OBJDIR_NAME)/include
|
||||
RELEASE_BIN_DIR = $(RELEASE_DIR)/$(BUILD_NUMBER)/$(OBJDIR_NAME)/bin
|
||||
RELEASE_LIB_DIR = $(RELEASE_DIR)/$(BUILD_NUMBER)/$(OBJDIR_NAME)/lib
|
||||
|
||||
# autoconf.mk sets OBJ_SUFFIX to an error to avoid use before including
|
||||
# this file
|
||||
OBJ_SUFFIX := $(_OBJ_SUFFIX)
|
||||
|
||||
# PGO builds with GCC build objects with instrumentation in a first pass,
|
||||
# then objects optimized, without instrumentation, in a second pass. If
|
||||
# we overwrite the ojects from the first pass with those from the second,
|
||||
# we end up not getting instrumentation data for better optimization on
|
||||
# incremental builds. As a consequence, we use a different object suffix
|
||||
# for the first pass.
|
||||
ifdef MOZ_PROFILE_GENERATE
|
||||
ifdef NS_USE_GCC
|
||||
OBJ_SUFFIX := i_o
|
||||
endif
|
||||
endif
|
||||
6
nsprpub/config/gcc_hidden.h
Normal file
6
nsprpub/config/gcc_hidden.h
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
/* Begin all files as hidden visibility */
|
||||
#pragma GCC visibility push(hidden)
|
||||
126
nsprpub/config/libc_r.h
Normal file
126
nsprpub/config/libc_r.h
Normal file
|
|
@ -0,0 +1,126 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
/* libc_r.h -- macros, defines, etc. to make using reentrant libc calls */
|
||||
/* a bit easier. This was initially done for AIX pthreads, */
|
||||
/* but should be usable for anyone... */
|
||||
|
||||
/* Most of these use locally defined space instead of static library space. */
|
||||
/* Because of this, we use the _INIT_R to declare/allocate space (stack), */
|
||||
/* and the plain routines to actually do it..._WARNING_: avoid allocating */
|
||||
/* memory wherever possible. Memory allocation is fairly expensive, at */
|
||||
/* least on AIX...use arrays instead (which allocate from the stack.) */
|
||||
/* I know the names are a bit strange, but I wanted to be fairly certain */
|
||||
/* that we didn't have any namespace corruption...in general, the inits are */
|
||||
/* R_<name>_INIT_R(), and the actual calls are R_<name>_R(). */
|
||||
|
||||
#ifndef _LIBC_R_H
|
||||
#define _LIBC_R_H
|
||||
|
||||
/************/
|
||||
/* strtok */
|
||||
/************/
|
||||
#define R_STRTOK_INIT_R() \
|
||||
char *r_strtok_r=NULL
|
||||
|
||||
#define R_STRTOK_R(return,source,delim) \
|
||||
return=strtok_r(source,delim,&r_strtok_r)
|
||||
|
||||
#define R_STRTOK_NORET_R(source,delim) \
|
||||
strtok_r(source,delim,&r_strtok_r)
|
||||
|
||||
/**************/
|
||||
/* strerror */
|
||||
/**************/
|
||||
#define R_MAX_STRERROR_LEN_R 8192 /* Straight from limits.h */
|
||||
|
||||
#define R_STRERROR_INIT_R() \
|
||||
char r_strerror_r[R_MAX_STRERROR_LEN_R]
|
||||
|
||||
#define R_STRERROR_R(val) \
|
||||
strerror_r(val,r_strerror_r,R_MAX_STRERROR_LEN_R)
|
||||
|
||||
/*****************/
|
||||
/* time things */
|
||||
/*****************/
|
||||
#define R_ASCTIME_INIT_R() \
|
||||
char r_asctime_r[26]
|
||||
|
||||
#define R_ASCTIME_R(val) \
|
||||
asctime_r(val,r_asctime_r)
|
||||
|
||||
#define R_CTIME_INIT_R() \
|
||||
char r_ctime_r[26]
|
||||
|
||||
#define R_CTIME_R(val) \
|
||||
ctime_r(val,r_ctime_r)
|
||||
|
||||
#define R_GMTIME_INIT_R() \
|
||||
struct tm r_gmtime_r
|
||||
|
||||
#define R_GMTIME_R(time) \
|
||||
gmtime_r(time,&r_gmtime_r)
|
||||
|
||||
#define R_LOCALTIME_INIT_R() \
|
||||
struct tm r_localtime_r
|
||||
|
||||
#define R_LOCALTIME_R(val) \
|
||||
localtime_r(val,&r_localtime_r)
|
||||
|
||||
/***********/
|
||||
/* crypt */
|
||||
/***********/
|
||||
#include <crypt.h>
|
||||
#define R_CRYPT_INIT_R() \
|
||||
CRYPTD r_cryptd_r; \
|
||||
bzero(&r_cryptd_r,sizeof(CRYPTD))
|
||||
|
||||
#define R_CRYPT_R(pass,salt) \
|
||||
crypt_r(pass,salt,&r_cryptd_r)
|
||||
|
||||
/**************/
|
||||
/* pw stuff */
|
||||
/**************/
|
||||
#define R_MAX_PW_LEN_R 1024
|
||||
/* The following must be after the last declaration, but */
|
||||
/* before the first bit of code... */
|
||||
#define R_GETPWNAM_INIT_R(pw_ptr) \
|
||||
struct passwd r_getpwnam_pw_r; \
|
||||
char r_getpwnam_line_r[R_MAX_PW_LEN_R]; \
|
||||
pw_ptr = &r_getpwnam_pw_r
|
||||
|
||||
#define R_GETPWNAM_R(name) \
|
||||
getpwnam_r(name,&r_getpwnam_pw_r,r_getpwnam_line_r,R_MAX_PW_LEN_R)
|
||||
|
||||
/*******************/
|
||||
/* gethost stuff */
|
||||
/*******************/
|
||||
#define R_GETHOSTBYADDR_INIT_R() \
|
||||
struct hostent r_gethostbyaddr_r; \
|
||||
struct hostent_data r_gethostbyaddr_data_r
|
||||
|
||||
#define R_GETHOSTBYADDR_R(addr,len,type,xptr_ent) \
|
||||
bzero(&r_gethostbyaddr_r,sizeof(struct hostent)); \
|
||||
bzero(&r_gethostbyaddr_data_r,sizeof(struct hostent_data)); \
|
||||
xptr_ent = &r_gethostbyaddr_r; \
|
||||
if (gethostbyaddr_r(addr,len,type, \
|
||||
&r_gethostbyaddr_r,&r_gethostbyaddr_data_r) == -1) { \
|
||||
xptr_ent = NULL; \
|
||||
}
|
||||
|
||||
#define R_GETHOSTBYNAME_INIT_R() \
|
||||
struct hostent r_gethostbyname_r; \
|
||||
struct hostent_data r_gethostbyname_data_r
|
||||
|
||||
#define R_GETHOSTBYNAME_R(name,xptr_ent) \
|
||||
bzero(&r_gethostbyname_r,sizeof(struct hostent)); \
|
||||
bzero(&r_gethostbyname_data_r,sizeof(struct hostent_data)); \
|
||||
xptr_ent = &r_gethostbyname_r; \
|
||||
if (gethostbyname_r(name, \
|
||||
&r_gethostbyname_r,&r_gethostbyname_data_r) == -1) { \
|
||||
xptr_ent = NULL; \
|
||||
}
|
||||
|
||||
#endif /* _LIBC_R_H */
|
||||
26
nsprpub/config/make-system-wrappers.pl
Normal file
26
nsprpub/config/make-system-wrappers.pl
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
#!/usr/bin/perl
|
||||
#
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
$output_dir = shift;
|
||||
|
||||
while (<STDIN>) {
|
||||
chomp;
|
||||
if (-e "$output_dir/$_") {
|
||||
next;
|
||||
}
|
||||
|
||||
if (/(.*)\/[^\/*]/) {
|
||||
mkdir "$output_dir/$1";
|
||||
}
|
||||
|
||||
open OUT, ">$output_dir/$_";
|
||||
print OUT "#pragma GCC system_header\n"; # suppress include_next warning
|
||||
print OUT "#pragma GCC visibility push(default)\n";
|
||||
print OUT "#include_next \<$_\>\n";
|
||||
print OUT "#pragma GCC visibility pop\n";
|
||||
close OUT;
|
||||
}
|
||||
|
||||
18
nsprpub/config/nfspwd.pl
Normal file
18
nsprpub/config/nfspwd.pl
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
#! perl
|
||||
#
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
require "fastcwd.pl";
|
||||
|
||||
$_ = &fastcwd;
|
||||
if (m@^/[uh]/@o || s@^/tmp_mnt/@/@o) {
|
||||
print("$_\n");
|
||||
} elsif ((($user, $rest) = m@^/usr/people/(\w+)/(.*)@o)
|
||||
&& readlink("/u/$user") eq "/usr/people/$user") {
|
||||
print("/u/$user/$rest\n");
|
||||
} else {
|
||||
chop($host = `hostname`);
|
||||
print("/h/$host$_\n");
|
||||
}
|
||||
41
nsprpub/config/now.c
Normal file
41
nsprpub/config/now.c
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
#if defined(OMIT_LIB_BUILD_TIME)
|
||||
/*
|
||||
* Some platforms don't have any 64-bit integer type
|
||||
* such as 'long long'. Because we can't use NSPR's
|
||||
* PR_snprintf in this program, it is difficult to
|
||||
* print a static initializer for PRInt64 (a struct).
|
||||
* So we print nothing. The makefiles that build the
|
||||
* shared libraries will detect the empty output string
|
||||
* of this program and omit the library build time
|
||||
* in PRVersionDescription.
|
||||
*/
|
||||
#elif defined(_MSC_VER)
|
||||
__int64 now;
|
||||
time_t sec;
|
||||
|
||||
sec = time(NULL);
|
||||
now = (1000000i64) * sec;
|
||||
fprintf(stdout, "%I64d", now);
|
||||
#else
|
||||
long long now;
|
||||
time_t sec;
|
||||
|
||||
sec = time(NULL);
|
||||
now = (1000000LL) * sec;
|
||||
fprintf(stdout, "%lld", now);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
} /* main */
|
||||
|
||||
/* now.c */
|
||||
525
nsprpub/config/nsinstall.c
Normal file
525
nsprpub/config/nsinstall.c
Normal file
|
|
@ -0,0 +1,525 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
/*
|
||||
** Netscape portable install command.
|
||||
**
|
||||
** Brendan Eich, 7/20/95
|
||||
*/
|
||||
#include <stdio.h> /* OSF/1 requires this before grp.h, so put it first */
|
||||
#include <assert.h>
|
||||
#include <fcntl.h>
|
||||
#include <grp.h>
|
||||
#include <pwd.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <utime.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
#include <stdarg.h>
|
||||
#ifdef USE_REENTRANT_LIBC
|
||||
#include "libc_r.h"
|
||||
#endif /* USE_REENTRANT_LIBC */
|
||||
|
||||
#include "pathsub.h"
|
||||
|
||||
#define HAVE_FCHMOD
|
||||
|
||||
#if defined(BEOS)
|
||||
#undef HAVE_FCHMOD
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Does getcwd() take NULL as the first argument and malloc
|
||||
* the result buffer?
|
||||
*/
|
||||
#if !defined(DARWIN)
|
||||
#define GETCWD_CAN_MALLOC
|
||||
#endif
|
||||
|
||||
#if defined(LINUX) || defined(__GNU__) || defined(__GLIBC__)
|
||||
#include <getopt.h>
|
||||
#endif
|
||||
|
||||
#if defined(SCO) || defined(UNIXWARE)
|
||||
#if !defined(S_ISLNK) && defined(S_IFLNK)
|
||||
#define S_ISLNK(a) (((a) & S_IFMT) == S_IFLNK)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef QNX
|
||||
#define d_ino d_stat.st_ino
|
||||
#endif
|
||||
|
||||
static void
|
||||
usage(void)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"usage: %s [-C cwd] [-L linkprefix] [-m mode] [-o owner] [-g group]\n"
|
||||
" %*s [-DdltR] file [file ...] directory\n",
|
||||
program, (int)strlen(program), "");
|
||||
exit(2);
|
||||
}
|
||||
|
||||
static int
|
||||
mkdirs(char *path, mode_t mode)
|
||||
{
|
||||
char *cp;
|
||||
struct stat sb;
|
||||
int res;
|
||||
|
||||
while (*path == '/' && path[1] == '/')
|
||||
path++;
|
||||
for (cp = strrchr(path, '/'); cp && cp != path && cp[-1] == '/'; cp--)
|
||||
;
|
||||
if (cp && cp != path) {
|
||||
*cp = '\0';
|
||||
if ((stat(path, &sb) < 0 || !S_ISDIR(sb.st_mode)) &&
|
||||
mkdirs(path, mode) < 0) {
|
||||
return -1;
|
||||
}
|
||||
*cp = '/';
|
||||
}
|
||||
res = mkdir(path, mode);
|
||||
if ((res != 0) && (errno == EEXIST))
|
||||
return 0;
|
||||
else
|
||||
return res;
|
||||
}
|
||||
|
||||
static uid_t
|
||||
touid(char *owner)
|
||||
{
|
||||
struct passwd *pw;
|
||||
uid_t uid;
|
||||
char *cp;
|
||||
|
||||
pw = getpwnam(owner);
|
||||
if (pw)
|
||||
return pw->pw_uid;
|
||||
uid = strtol(owner, &cp, 0);
|
||||
if (uid == 0 && cp == owner)
|
||||
fail("cannot find uid for %s", owner);
|
||||
return uid;
|
||||
}
|
||||
|
||||
static gid_t
|
||||
togid(char *group)
|
||||
{
|
||||
struct group *gr;
|
||||
gid_t gid;
|
||||
char *cp;
|
||||
|
||||
gr = getgrnam(group);
|
||||
if (gr)
|
||||
return gr->gr_gid;
|
||||
gid = strtol(group, &cp, 0);
|
||||
if (gid == 0 && cp == group)
|
||||
fail("cannot find gid for %s", group);
|
||||
return gid;
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
int onlydir, dodir, dolink, dorelsymlink, dotimes, opt, len, lplen, tdlen, bnlen, exists, fromfd, tofd, cc, wc;
|
||||
mode_t mode = 0755;
|
||||
char *linkprefix, *owner, *group, *cp, *cwd, *todir, *toname, *name, *base, *linkname, *bp, buf[BUFSIZ];
|
||||
uid_t uid;
|
||||
gid_t gid;
|
||||
struct stat sb, tosb;
|
||||
struct utimbuf utb;
|
||||
|
||||
program = argv[0];
|
||||
cwd = linkname = linkprefix = owner = group = 0;
|
||||
onlydir = dodir = dolink = dorelsymlink = dotimes = lplen = 0;
|
||||
|
||||
while ((opt = getopt(argc, argv, "C:DdlL:Rm:o:g:t")) != EOF) {
|
||||
switch (opt) {
|
||||
case 'C':
|
||||
cwd = optarg;
|
||||
break;
|
||||
case 'D':
|
||||
onlydir = 1;
|
||||
break;
|
||||
case 'd':
|
||||
dodir = 1;
|
||||
break;
|
||||
case 'l':
|
||||
dolink = 1;
|
||||
break;
|
||||
case 'L':
|
||||
linkprefix = optarg;
|
||||
lplen = strlen(linkprefix);
|
||||
dolink = 1;
|
||||
break;
|
||||
case 'R':
|
||||
dolink = dorelsymlink = 1;
|
||||
break;
|
||||
case 'm':
|
||||
mode = strtoul(optarg, &cp, 8);
|
||||
if (mode == 0 && cp == optarg)
|
||||
usage();
|
||||
break;
|
||||
case 'o':
|
||||
owner = optarg;
|
||||
break;
|
||||
case 'g':
|
||||
group = optarg;
|
||||
break;
|
||||
case 't':
|
||||
dotimes = 1;
|
||||
break;
|
||||
default:
|
||||
usage();
|
||||
}
|
||||
}
|
||||
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
if (argc < 2 - onlydir)
|
||||
usage();
|
||||
|
||||
todir = argv[argc-1];
|
||||
if ((stat(todir, &sb) < 0 || !S_ISDIR(sb.st_mode)) &&
|
||||
mkdirs(todir, 0777) < 0) {
|
||||
fail("cannot make directory %s", todir);
|
||||
}
|
||||
if (onlydir)
|
||||
return 0;
|
||||
|
||||
if (!cwd) {
|
||||
#ifdef GETCWD_CAN_MALLOC
|
||||
cwd = getcwd(0, PATH_MAX);
|
||||
#else
|
||||
cwd = malloc(PATH_MAX + 1);
|
||||
cwd = getcwd(cwd, PATH_MAX);
|
||||
#endif
|
||||
}
|
||||
xchdir(todir);
|
||||
#ifdef GETCWD_CAN_MALLOC
|
||||
todir = getcwd(0, PATH_MAX);
|
||||
#else
|
||||
todir = malloc(PATH_MAX + 1);
|
||||
todir = getcwd(todir, PATH_MAX);
|
||||
#endif
|
||||
xchdir(cwd);
|
||||
tdlen = strlen(todir);
|
||||
|
||||
uid = owner ? touid(owner) : -1;
|
||||
gid = group ? togid(group) : -1;
|
||||
|
||||
while (--argc > 0) {
|
||||
name = *argv++;
|
||||
len = strlen(name);
|
||||
base = xbasename(name);
|
||||
bnlen = strlen(base);
|
||||
toname = (char*)xmalloc(tdlen + 1 + bnlen + 1);
|
||||
sprintf(toname, "%s/%s", todir, base);
|
||||
exists = (lstat(toname, &tosb) == 0);
|
||||
|
||||
if (dodir) {
|
||||
/* -d means create a directory, always */
|
||||
if (exists && !S_ISDIR(tosb.st_mode)) {
|
||||
(void) unlink(toname);
|
||||
exists = 0;
|
||||
}
|
||||
if (!exists && mkdir(toname, mode) < 0)
|
||||
fail("cannot make directory %s", toname);
|
||||
if ((owner || group) && chown(toname, uid, gid) < 0)
|
||||
fail("cannot change owner of %s", toname);
|
||||
} else if (dolink) {
|
||||
if (*name == '/') {
|
||||
/* source is absolute pathname, link to it directly */
|
||||
linkname = 0;
|
||||
} else {
|
||||
if (linkprefix) {
|
||||
/* -L implies -l and prefixes names with a $cwd arg. */
|
||||
len += lplen + 1;
|
||||
linkname = (char*)xmalloc(len + 1);
|
||||
sprintf(linkname, "%s/%s", linkprefix, name);
|
||||
} else if (dorelsymlink) {
|
||||
/* Symlink the relative path from todir to source name. */
|
||||
linkname = (char*)xmalloc(PATH_MAX);
|
||||
|
||||
if (*todir == '/') {
|
||||
/* todir is absolute: skip over common prefix. */
|
||||
lplen = relatepaths(todir, cwd, linkname);
|
||||
strcpy(linkname + lplen, name);
|
||||
} else {
|
||||
/* todir is named by a relative path: reverse it. */
|
||||
reversepath(todir, name, len, linkname);
|
||||
xchdir(cwd);
|
||||
}
|
||||
|
||||
len = strlen(linkname);
|
||||
}
|
||||
name = linkname;
|
||||
}
|
||||
|
||||
/* Check for a pre-existing symlink with identical content. */
|
||||
if (exists &&
|
||||
(!S_ISLNK(tosb.st_mode) ||
|
||||
readlink(toname, buf, sizeof buf) != len ||
|
||||
strncmp(buf, name, len) != 0)) {
|
||||
(void) (S_ISDIR(tosb.st_mode) ? rmdir : unlink)(toname);
|
||||
exists = 0;
|
||||
}
|
||||
if (!exists && symlink(name, toname) < 0)
|
||||
fail("cannot make symbolic link %s", toname);
|
||||
#ifdef HAVE_LCHOWN
|
||||
if ((owner || group) && lchown(toname, uid, gid) < 0)
|
||||
fail("cannot change owner of %s", toname);
|
||||
#endif
|
||||
|
||||
if (linkname) {
|
||||
free(linkname);
|
||||
linkname = 0;
|
||||
}
|
||||
} else {
|
||||
/* Copy from name to toname, which might be the same file. */
|
||||
fromfd = open(name, O_RDONLY);
|
||||
if (fromfd < 0 || fstat(fromfd, &sb) < 0)
|
||||
fail("cannot access %s", name);
|
||||
if (exists && (!S_ISREG(tosb.st_mode) || access(toname, W_OK) < 0))
|
||||
(void) (S_ISDIR(tosb.st_mode) ? rmdir : unlink)(toname);
|
||||
tofd = open(toname, O_CREAT | O_WRONLY, 0666);
|
||||
if (tofd < 0)
|
||||
fail("cannot create %s", toname);
|
||||
|
||||
bp = buf;
|
||||
while ((cc = read(fromfd, bp, sizeof buf)) > 0) {
|
||||
while ((wc = write(tofd, bp, cc)) > 0) {
|
||||
if ((cc -= wc) == 0)
|
||||
break;
|
||||
bp += wc;
|
||||
}
|
||||
if (wc < 0)
|
||||
fail("cannot write to %s", toname);
|
||||
}
|
||||
if (cc < 0)
|
||||
fail("cannot read from %s", name);
|
||||
|
||||
if (ftruncate(tofd, sb.st_size) < 0)
|
||||
fail("cannot truncate %s", toname);
|
||||
if (dotimes) {
|
||||
utb.actime = sb.st_atime;
|
||||
utb.modtime = sb.st_mtime;
|
||||
if (utime(toname, &utb) < 0)
|
||||
fail("cannot set times of %s", toname);
|
||||
}
|
||||
#ifdef HAVE_FCHMOD
|
||||
if (fchmod(tofd, mode) < 0)
|
||||
#else
|
||||
if (chmod(toname, mode) < 0)
|
||||
#endif
|
||||
fail("cannot change mode of %s", toname);
|
||||
if ((owner || group) && fchown(tofd, uid, gid) < 0)
|
||||
fail("cannot change owner of %s", toname);
|
||||
|
||||
/* Must check for delayed (NFS) write errors on close. */
|
||||
if (close(tofd) < 0)
|
||||
fail("cannot write to %s", toname);
|
||||
close(fromfd);
|
||||
}
|
||||
|
||||
free(toname);
|
||||
}
|
||||
|
||||
free(cwd);
|
||||
free(todir);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
** Pathname subroutines.
|
||||
**
|
||||
** Brendan Eich, 8/29/95
|
||||
*/
|
||||
|
||||
char *program;
|
||||
|
||||
void
|
||||
fail(char *format, ...)
|
||||
{
|
||||
int error;
|
||||
va_list ap;
|
||||
|
||||
#ifdef USE_REENTRANT_LIBC
|
||||
R_STRERROR_INIT_R();
|
||||
#endif
|
||||
|
||||
error = errno;
|
||||
fprintf(stderr, "%s: ", program);
|
||||
va_start(ap, format);
|
||||
vfprintf(stderr, format, ap);
|
||||
va_end(ap);
|
||||
if (error)
|
||||
|
||||
#ifdef USE_REENTRANT_LIBC
|
||||
R_STRERROR_R(errno);
|
||||
fprintf(stderr, ": %s", r_strerror_r);
|
||||
#else
|
||||
fprintf(stderr, ": %s", strerror(errno));
|
||||
#endif
|
||||
|
||||
putc('\n', stderr);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
char *
|
||||
getcomponent(char *path, char *name)
|
||||
{
|
||||
if (*path == '\0')
|
||||
return 0;
|
||||
if (*path == '/') {
|
||||
*name++ = '/';
|
||||
} else {
|
||||
do {
|
||||
*name++ = *path++;
|
||||
} while (*path != '/' && *path != '\0');
|
||||
}
|
||||
*name = '\0';
|
||||
while (*path == '/')
|
||||
path++;
|
||||
return path;
|
||||
}
|
||||
|
||||
#ifdef UNIXWARE_READDIR_BUFFER_TOO_SMALL
|
||||
/* Sigh. The static buffer in Unixware's readdir is too small. */
|
||||
struct dirent * readdir(DIR *d)
|
||||
{
|
||||
static struct dirent *buf = NULL;
|
||||
#define MAX_PATH_LEN 1024
|
||||
|
||||
|
||||
if(buf == NULL)
|
||||
buf = (struct dirent *) malloc(sizeof(struct dirent) + MAX_PATH_LEN)
|
||||
;
|
||||
return(readdir_r(d, buf));
|
||||
}
|
||||
#endif
|
||||
|
||||
char *
|
||||
ino2name(ino_t ino, char *dir)
|
||||
{
|
||||
DIR *dp;
|
||||
struct dirent *ep;
|
||||
char *name;
|
||||
|
||||
dp = opendir("..");
|
||||
if (!dp)
|
||||
fail("cannot read parent directory");
|
||||
for (;;) {
|
||||
if (!(ep = readdir(dp)))
|
||||
fail("cannot find current directory");
|
||||
if (ep->d_ino == ino)
|
||||
break;
|
||||
}
|
||||
name = xstrdup(ep->d_name);
|
||||
closedir(dp);
|
||||
return name;
|
||||
}
|
||||
|
||||
void *
|
||||
xmalloc(size_t size)
|
||||
{
|
||||
void *p = malloc(size);
|
||||
if (!p)
|
||||
fail("cannot allocate %u bytes", size);
|
||||
return p;
|
||||
}
|
||||
|
||||
char *
|
||||
xstrdup(char *s)
|
||||
{
|
||||
return strcpy((char*)xmalloc(strlen(s) + 1), s);
|
||||
}
|
||||
|
||||
char *
|
||||
xbasename(char *path)
|
||||
{
|
||||
char *cp;
|
||||
|
||||
while ((cp = strrchr(path, '/')) && cp[1] == '\0')
|
||||
*cp = '\0';
|
||||
if (!cp) return path;
|
||||
return cp + 1;
|
||||
}
|
||||
|
||||
void
|
||||
xchdir(char *dir)
|
||||
{
|
||||
if (chdir(dir) < 0)
|
||||
fail("cannot change directory to %s", dir);
|
||||
}
|
||||
|
||||
int
|
||||
relatepaths(char *from, char *to, char *outpath)
|
||||
{
|
||||
char *cp, *cp2;
|
||||
int len;
|
||||
char buf[NAME_MAX];
|
||||
|
||||
assert(*from == '/' && *to == '/');
|
||||
for (cp = to, cp2 = from; *cp == *cp2; cp++, cp2++)
|
||||
if (*cp == '\0')
|
||||
break;
|
||||
while (cp[-1] != '/')
|
||||
cp--, cp2--;
|
||||
if (cp - 1 == to) {
|
||||
/* closest common ancestor is /, so use full pathname */
|
||||
len = strlen(strcpy(outpath, to));
|
||||
if (outpath[len] != '/') {
|
||||
outpath[len++] = '/';
|
||||
outpath[len] = '\0';
|
||||
}
|
||||
} else {
|
||||
len = 0;
|
||||
while ((cp2 = getcomponent(cp2, buf)) != 0) {
|
||||
strcpy(outpath + len, "../");
|
||||
len += 3;
|
||||
}
|
||||
while ((cp = getcomponent(cp, buf)) != 0) {
|
||||
sprintf(outpath + len, "%s/", buf);
|
||||
len += strlen(outpath + len);
|
||||
}
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
void
|
||||
reversepath(char *inpath, char *name, int len, char *outpath)
|
||||
{
|
||||
char *cp, *cp2;
|
||||
char buf[NAME_MAX];
|
||||
struct stat sb;
|
||||
|
||||
cp = strcpy(outpath + PATH_MAX - (len + 1), name);
|
||||
cp2 = inpath;
|
||||
while ((cp2 = getcomponent(cp2, buf)) != 0) {
|
||||
if (strcmp(buf, ".") == 0)
|
||||
continue;
|
||||
if (strcmp(buf, "..") == 0) {
|
||||
if (stat(".", &sb) < 0)
|
||||
fail("cannot stat current directory");
|
||||
name = ino2name(sb.st_ino, "..");
|
||||
len = strlen(name);
|
||||
cp -= len + 1;
|
||||
strcpy(cp, name);
|
||||
cp[len] = '/';
|
||||
free(name);
|
||||
xchdir("..");
|
||||
} else {
|
||||
cp -= 3;
|
||||
strncpy(cp, "../", 3);
|
||||
xchdir(buf);
|
||||
}
|
||||
}
|
||||
strcpy(outpath, cp);
|
||||
}
|
||||
147
nsprpub/config/nspr-config.in
Normal file
147
nsprpub/config/nspr-config.in
Normal file
|
|
@ -0,0 +1,147 @@
|
|||
#!/bin/sh
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
|
||||
prefix=@prefix@
|
||||
|
||||
major_version=@MOD_MAJOR_VERSION@
|
||||
minor_version=@MOD_MINOR_VERSION@
|
||||
patch_version=@MOD_PATCH_VERSION@
|
||||
|
||||
usage()
|
||||
{
|
||||
cat <<EOF
|
||||
Usage: nspr-config [OPTIONS] [LIBRARIES]
|
||||
Options:
|
||||
[--prefix[=DIR]]
|
||||
[--exec-prefix[=DIR]]
|
||||
[--includedir[=DIR]]
|
||||
[--libdir[=DIR]]
|
||||
[--version]
|
||||
[--libs]
|
||||
[--cflags]
|
||||
Libraries:
|
||||
nspr
|
||||
plc
|
||||
plds
|
||||
EOF
|
||||
exit $1
|
||||
}
|
||||
|
||||
if test $# -eq 0; then
|
||||
usage 1 1>&2
|
||||
fi
|
||||
|
||||
lib_nspr=yes
|
||||
lib_plc=yes
|
||||
lib_plds=yes
|
||||
|
||||
while test $# -gt 0; do
|
||||
case "$1" in
|
||||
-*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
|
||||
*) optarg= ;;
|
||||
esac
|
||||
|
||||
case $1 in
|
||||
--prefix=*)
|
||||
prefix=$optarg
|
||||
;;
|
||||
--prefix)
|
||||
echo_prefix=yes
|
||||
;;
|
||||
--exec-prefix=*)
|
||||
exec_prefix=$optarg
|
||||
;;
|
||||
--exec-prefix)
|
||||
echo_exec_prefix=yes
|
||||
;;
|
||||
--includedir=*)
|
||||
includedir=$optarg
|
||||
;;
|
||||
--includedir)
|
||||
echo_includedir=yes
|
||||
;;
|
||||
--libdir=*)
|
||||
libdir=$optarg
|
||||
;;
|
||||
--libdir)
|
||||
echo_libdir=yes
|
||||
;;
|
||||
--version)
|
||||
echo ${major_version}.${minor_version}.${patch_version}
|
||||
;;
|
||||
--cflags)
|
||||
echo_cflags=yes
|
||||
;;
|
||||
--libs)
|
||||
echo_libs=yes
|
||||
;;
|
||||
nspr)
|
||||
lib_nspr=yes
|
||||
;;
|
||||
plc)
|
||||
lib_plc=yes
|
||||
;;
|
||||
plds)
|
||||
lib_plds=yes
|
||||
;;
|
||||
*)
|
||||
usage 1 1>&2
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
# Set variables that may be dependent upon other variables
|
||||
if test -z "$exec_prefix"; then
|
||||
exec_prefix=@exec_prefix@
|
||||
fi
|
||||
if test -z "$includedir"; then
|
||||
includedir=@includedir@
|
||||
fi
|
||||
if test -z "$libdir"; then
|
||||
libdir=@libdir@
|
||||
fi
|
||||
|
||||
if test "$echo_prefix" = "yes"; then
|
||||
echo $prefix
|
||||
fi
|
||||
|
||||
if test "$echo_exec_prefix" = "yes"; then
|
||||
echo $exec_prefix
|
||||
fi
|
||||
|
||||
if test "$echo_includedir" = "yes"; then
|
||||
echo $includedir
|
||||
fi
|
||||
|
||||
if test "$echo_libdir" = "yes"; then
|
||||
echo $libdir
|
||||
fi
|
||||
|
||||
if test "$echo_cflags" = "yes"; then
|
||||
echo -I$includedir
|
||||
fi
|
||||
|
||||
if test "$echo_libs" = "yes"; then
|
||||
libdirs=-L$libdir
|
||||
if test -n "$lib_plds"; then
|
||||
libdirs="$libdirs -lplds${major_version}"
|
||||
fi
|
||||
if test -n "$lib_plc"; then
|
||||
libdirs="$libdirs -lplc${major_version}"
|
||||
fi
|
||||
if test -n "$lib_nspr"; then
|
||||
libdirs="$libdirs -lnspr${major_version}"
|
||||
fi
|
||||
os_ldflags="@LDFLAGS@"
|
||||
for i in $os_ldflags ; do
|
||||
if echo $i | grep \^-L >/dev/null; then
|
||||
libdirs="$libdirs $i"
|
||||
fi
|
||||
done
|
||||
echo $libdirs @OS_LIBS@
|
||||
fi
|
||||
|
||||
82
nsprpub/config/nspr.m4
Normal file
82
nsprpub/config/nspr.m4
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
# -*- tab-width: 4; -*-
|
||||
# Configure paths for NSPR
|
||||
# Public domain - Chris Seawood <cls@seawood.org> 2001-04-05
|
||||
# Based upon gtk.m4 (also PD) by Owen Taylor
|
||||
|
||||
dnl AM_PATH_NSPR([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
|
||||
dnl Test for NSPR, and define NSPR_CFLAGS and NSPR_LIBS
|
||||
AC_DEFUN([AM_PATH_NSPR],
|
||||
[dnl
|
||||
|
||||
AC_ARG_WITH(nspr-prefix,
|
||||
[ --with-nspr-prefix=PFX Prefix where NSPR is installed],
|
||||
nspr_config_prefix="$withval",
|
||||
nspr_config_prefix="")
|
||||
|
||||
AC_ARG_WITH(nspr-exec-prefix,
|
||||
[ --with-nspr-exec-prefix=PFX
|
||||
Exec prefix where NSPR is installed],
|
||||
nspr_config_exec_prefix="$withval",
|
||||
nspr_config_exec_prefix="")
|
||||
|
||||
if test -n "$nspr_config_exec_prefix"; then
|
||||
nspr_config_args="$nspr_config_args --exec-prefix=$nspr_config_exec_prefix"
|
||||
if test -z "$NSPR_CONFIG"; then
|
||||
NSPR_CONFIG=$nspr_config_exec_prefix/bin/nspr-config
|
||||
fi
|
||||
fi
|
||||
if test -n "$nspr_config_prefix"; then
|
||||
nspr_config_args="$nspr_config_args --prefix=$nspr_config_prefix"
|
||||
if test -z "$NSPR_CONFIG"; then
|
||||
NSPR_CONFIG=$nspr_config_prefix/bin/nspr-config
|
||||
fi
|
||||
fi
|
||||
|
||||
unset ac_cv_path_NSPR_CONFIG
|
||||
AC_PATH_PROG(NSPR_CONFIG, nspr-config, no)
|
||||
min_nspr_version=ifelse([$1], ,4.0.0,$1)
|
||||
AC_MSG_CHECKING(for NSPR - version >= $min_nspr_version)
|
||||
|
||||
no_nspr=""
|
||||
if test "$NSPR_CONFIG" = "no"; then
|
||||
no_nspr="yes"
|
||||
else
|
||||
NSPR_CFLAGS=`$NSPR_CONFIG $nspr_config_args --cflags`
|
||||
NSPR_LIBS=`$NSPR_CONFIG $nspr_config_args --libs`
|
||||
|
||||
nspr_config_major_version=`$NSPR_CONFIG $nspr_config_args --version | \
|
||||
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
|
||||
nspr_config_minor_version=`$NSPR_CONFIG $nspr_config_args --version | \
|
||||
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
|
||||
nspr_config_micro_version=`$NSPR_CONFIG $nspr_config_args --version | \
|
||||
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
|
||||
min_nspr_major_version=`echo $min_nspr_version | \
|
||||
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
|
||||
min_nspr_minor_version=`echo $min_nspr_version | \
|
||||
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
|
||||
min_nspr_micro_version=`echo $min_nspr_version | \
|
||||
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
|
||||
if test "$nspr_config_major_version" -ne "$min_nspr_major_version"; then
|
||||
no_nspr="yes"
|
||||
elif test "$nspr_config_major_version" -eq "$min_nspr_major_version" &&
|
||||
test "$nspr_config_minor_version" -lt "$min_nspr_minor_version"; then
|
||||
no_nspr="yes"
|
||||
elif test "$nspr_config_major_version" -eq "$min_nspr_major_version" &&
|
||||
test "$nspr_config_minor_version" -eq "$min_nspr_minor_version" &&
|
||||
test "$nspr_config_micro_version" -lt "$min_nspr_micro_version"; then
|
||||
no_nspr="yes"
|
||||
fi
|
||||
fi
|
||||
|
||||
if test -z "$no_nspr"; then
|
||||
AC_MSG_RESULT(yes)
|
||||
ifelse([$2], , :, [$2])
|
||||
else
|
||||
AC_MSG_RESULT(no)
|
||||
fi
|
||||
|
||||
|
||||
AC_SUBST(NSPR_CFLAGS)
|
||||
AC_SUBST(NSPR_LIBS)
|
||||
|
||||
])
|
||||
10
nsprpub/config/nspr.pc.in
Normal file
10
nsprpub/config/nspr.pc.in
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
prefix=@prefix@
|
||||
exec_prefix=@exec_prefix@
|
||||
libdir=@libdir@
|
||||
includedir=@includedir@
|
||||
|
||||
Name: NSPR
|
||||
Description: The Netscape Portable Runtime
|
||||
Version: @MOD_MAJOR_VERSION@.@MOD_MINOR_VERSION@.@MOD_PATCH_VERSION@
|
||||
Libs: -L@libdir@ -lplds@MOD_MAJOR_VERSION@ -lplc@MOD_MAJOR_VERSION@ -lnspr@MOD_MAJOR_VERSION@
|
||||
Cflags: -I@includedir@
|
||||
9
nsprpub/config/nsprincl.mk.in
Normal file
9
nsprpub/config/nsprincl.mk.in
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
# Include in Makefiles to define NSPR variables
|
||||
|
||||
NSPR_VERSION = @NSPR_VERSION@
|
||||
NSPR_LIB = -lnspr@NSPR_VERSION@
|
||||
NSPR_EXTRA_LIBS = @EXTRA_LIBS@
|
||||
9
nsprpub/config/nsprincl.sh.in
Normal file
9
nsprpub/config/nsprincl.sh.in
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
# Include in shell scripts to define NSPR variables
|
||||
|
||||
NSPR_VERSION=@NSPR_VERSION@
|
||||
NSPR_LIB=-lnspr$NSPR_VERSION
|
||||
NSPR_EXTRA_LIBS="@EXTRA_LIBS@"
|
||||
42
nsprpub/config/pathsub.h
Normal file
42
nsprpub/config/pathsub.h
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef pathsub_h___
|
||||
#define pathsub_h___
|
||||
/*
|
||||
** Pathname subroutines.
|
||||
**
|
||||
** Brendan Eich, 8/29/95
|
||||
*/
|
||||
#include <limits.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifndef PATH_MAX
|
||||
#define PATH_MAX 1024
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Just prevent stupidity
|
||||
*/
|
||||
#undef NAME_MAX
|
||||
#define NAME_MAX 256
|
||||
|
||||
extern char *program;
|
||||
|
||||
extern void fail(char *format, ...);
|
||||
extern char *getcomponent(char *path, char *name);
|
||||
extern char *ino2name(ino_t ino, char *dir);
|
||||
extern void *xmalloc(size_t size);
|
||||
extern char *xstrdup(char *s);
|
||||
extern char *xbasename(char *path);
|
||||
extern void xchdir(char *dir);
|
||||
|
||||
/* Relate absolute pathnames from and to returning the result in outpath. */
|
||||
extern int relatepaths(char *from, char *to, char *outpath);
|
||||
|
||||
/* XXX changes current working directory -- caveat emptor */
|
||||
extern void reversepath(char *inpath, char *name, int len, char *outpath);
|
||||
|
||||
#endif /* pathsub_h___ */
|
||||
13
nsprpub/config/prdepend.h
Normal file
13
nsprpub/config/prdepend.h
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
/*
|
||||
* A dummy header file that is a dependency for all the object files.
|
||||
* Used to force a full recompilation of NSPR in Mozilla's Tinderbox
|
||||
* depend builds. See comments in rules.mk.
|
||||
*/
|
||||
|
||||
#error "Do not include this header file."
|
||||
|
||||
527
nsprpub/config/rules.mk
Normal file
527
nsprpub/config/rules.mk
Normal file
|
|
@ -0,0 +1,527 @@
|
|||
#! gmake
|
||||
#
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
################################################################################
|
||||
# We used to have a 4 pass build process. Now we do everything in one pass.
|
||||
#
|
||||
# export - Create generated headers and stubs. Publish public headers to
|
||||
# dist/<arch>/include.
|
||||
# Create libraries. Publish libraries to dist/<arch>/lib.
|
||||
# Create programs.
|
||||
#
|
||||
# libs - obsolete. Now a synonym of "export".
|
||||
#
|
||||
# all - the default makefile target. Now a synonym of "export".
|
||||
#
|
||||
# install - Install headers, libraries, and programs on the system.
|
||||
#
|
||||
# Parameters to this makefile (set these before including):
|
||||
#
|
||||
# a)
|
||||
# TARGETS -- the target to create
|
||||
# (defaults to $LIBRARY $PROGRAM)
|
||||
# b)
|
||||
# DIRS -- subdirectories for make to recurse on
|
||||
# (the 'all' rule builds $TARGETS $DIRS)
|
||||
# c)
|
||||
# CSRCS -- .c files to compile
|
||||
# (used to define $OBJS)
|
||||
# d)
|
||||
# PROGRAM -- the target program name to create from $OBJS
|
||||
# ($OBJDIR automatically prepended to it)
|
||||
# e)
|
||||
# LIBRARY -- the target library name to create from $OBJS
|
||||
# ($OBJDIR automatically prepended to it)
|
||||
#
|
||||
################################################################################
|
||||
|
||||
ifndef topsrcdir
|
||||
topsrcdir=$(MOD_DEPTH)
|
||||
endif
|
||||
|
||||
ifndef srcdir
|
||||
srcdir=.
|
||||
endif
|
||||
|
||||
ifndef NSPR_CONFIG_MK
|
||||
include $(topsrcdir)/config/config.mk
|
||||
endif
|
||||
|
||||
ifdef USE_AUTOCONF
|
||||
ifdef CROSS_COMPILE
|
||||
ifdef INTERNAL_TOOLS
|
||||
CC=$(HOST_CC)
|
||||
CCC=$(HOST_CXX)
|
||||
CFLAGS=$(HOST_CFLAGS)
|
||||
CXXFLAGS=$(HOST_CXXFLAGS)
|
||||
LDFLAGS=$(HOST_LDFLAGS)
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
#
|
||||
# This makefile contains rules for building the following kinds of
|
||||
# libraries:
|
||||
# - LIBRARY: a static (archival) library
|
||||
# - SHARED_LIBRARY: a shared (dynamic link) library
|
||||
# - IMPORT_LIBRARY: an import library, used only on Windows and OS/2
|
||||
#
|
||||
# The names of these libraries can be generated by simply specifying
|
||||
# LIBRARY_NAME and LIBRARY_VERSION.
|
||||
#
|
||||
|
||||
ifdef LIBRARY_NAME
|
||||
ifeq (,$(filter-out WINNT WINCE OS2,$(OS_ARCH)))
|
||||
|
||||
#
|
||||
# Win95 and OS/2 require library names conforming to the 8.3 rule.
|
||||
# other platforms do not.
|
||||
#
|
||||
ifeq (,$(filter-out WIN95 WINCE WINMO OS2,$(OS_TARGET)))
|
||||
SHARED_LIBRARY = $(OBJDIR)/$(LIBRARY_NAME)$(LIBRARY_VERSION).$(DLL_SUFFIX)
|
||||
SHARED_LIB_PDB = $(OBJDIR)/$(LIBRARY_NAME)$(LIBRARY_VERSION).pdb
|
||||
ifdef MSC_VER
|
||||
LIBRARY = $(OBJDIR)/$(LIBRARY_NAME)$(LIBRARY_VERSION)_s.$(LIB_SUFFIX)
|
||||
IMPORT_LIBRARY = $(OBJDIR)/$(LIBRARY_NAME)$(LIBRARY_VERSION).$(LIB_SUFFIX)
|
||||
else
|
||||
LIBRARY = $(OBJDIR)/lib$(LIBRARY_NAME)$(LIBRARY_VERSION)_s.$(LIB_SUFFIX)
|
||||
IMPORT_LIBRARY = $(OBJDIR)/lib$(LIBRARY_NAME)$(LIBRARY_VERSION).$(LIB_SUFFIX)
|
||||
endif
|
||||
else
|
||||
SHARED_LIBRARY = $(OBJDIR)/lib$(LIBRARY_NAME)$(LIBRARY_VERSION).$(DLL_SUFFIX)
|
||||
SHARED_LIB_PDB = $(OBJDIR)/lib$(LIBRARY_NAME)$(LIBRARY_VERSION).pdb
|
||||
LIBRARY = $(OBJDIR)/lib$(LIBRARY_NAME)$(LIBRARY_VERSION)_s.$(LIB_SUFFIX)
|
||||
IMPORT_LIBRARY = $(OBJDIR)/lib$(LIBRARY_NAME)$(LIBRARY_VERSION).$(LIB_SUFFIX)
|
||||
endif
|
||||
|
||||
else
|
||||
|
||||
LIBRARY = $(OBJDIR)/lib$(LIBRARY_NAME)$(LIBRARY_VERSION).$(LIB_SUFFIX)
|
||||
ifeq ($(OS_ARCH)$(OS_RELEASE), AIX4.1)
|
||||
SHARED_LIBRARY = $(OBJDIR)/lib$(LIBRARY_NAME)$(LIBRARY_VERSION)_shr.a
|
||||
else
|
||||
ifdef MKSHLIB
|
||||
SHARED_LIBRARY = $(OBJDIR)/lib$(LIBRARY_NAME)$(LIBRARY_VERSION).$(DLL_SUFFIX)
|
||||
endif
|
||||
endif
|
||||
|
||||
endif
|
||||
endif
|
||||
|
||||
ifndef TARGETS
|
||||
ifeq (,$(filter-out WINNT WINCE OS2,$(OS_ARCH)))
|
||||
TARGETS = $(LIBRARY) $(SHARED_LIBRARY) $(IMPORT_LIBRARY)
|
||||
ifdef MOZ_DEBUG_SYMBOLS
|
||||
ifdef MSC_VER
|
||||
ifneq (,$(filter-out 1100 1200,$(MSC_VER)))
|
||||
TARGETS += $(SHARED_LIB_PDB)
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
else
|
||||
TARGETS = $(LIBRARY) $(SHARED_LIBRARY)
|
||||
endif
|
||||
endif
|
||||
|
||||
#
|
||||
# OBJS is the list of object files. It can be constructed by
|
||||
# specifying CSRCS (list of C source files) and ASFILES (list
|
||||
# of assembly language source files).
|
||||
#
|
||||
|
||||
ifndef OBJS
|
||||
OBJS = $(addprefix $(OBJDIR)/,$(CSRCS:.c=.$(OBJ_SUFFIX))) \
|
||||
$(addprefix $(OBJDIR)/,$(ASFILES:.$(ASM_SUFFIX)=.$(OBJ_SUFFIX)))
|
||||
endif
|
||||
|
||||
ALL_TRASH = $(TARGETS) $(OBJS) $(RES) $(filter-out . .., $(OBJDIR)) LOGS TAGS $(GARBAGE) \
|
||||
$(NOSUCHFILE) \
|
||||
$(OBJS:.$(OBJ_SUFFIX)=.i_o) \
|
||||
so_locations
|
||||
|
||||
ifndef RELEASE_LIBS_DEST
|
||||
RELEASE_LIBS_DEST = $(RELEASE_LIB_DIR)
|
||||
endif
|
||||
|
||||
define MAKE_IN_DIR
|
||||
$(MAKE) -C $(dir) $@
|
||||
|
||||
endef # do not remove the blank line!
|
||||
|
||||
ifdef DIRS
|
||||
LOOP_OVER_DIRS = $(foreach dir,$(DIRS),$(MAKE_IN_DIR))
|
||||
endif
|
||||
|
||||
################################################################################
|
||||
|
||||
all:: export
|
||||
|
||||
export::
|
||||
+$(LOOP_OVER_DIRS)
|
||||
|
||||
libs:: export
|
||||
|
||||
clean::
|
||||
rm -rf $(OBJS) $(RES) so_locations $(NOSUCHFILE) $(GARBAGE)
|
||||
+$(LOOP_OVER_DIRS)
|
||||
|
||||
clobber::
|
||||
rm -rf $(OBJS) $(RES) $(TARGETS) $(filter-out . ..,$(OBJDIR)) $(GARBAGE) so_locations $(NOSUCHFILE)
|
||||
+$(LOOP_OVER_DIRS)
|
||||
|
||||
realclean clobber_all::
|
||||
rm -rf $(wildcard *.OBJ *.OBJD) dist $(ALL_TRASH)
|
||||
+$(LOOP_OVER_DIRS)
|
||||
|
||||
distclean::
|
||||
rm -rf $(wildcard *.OBJ *.OBJD) dist $(ALL_TRASH) $(DIST_GARBAGE)
|
||||
+$(LOOP_OVER_DIRS)
|
||||
|
||||
install:: $(RELEASE_BINS) $(RELEASE_HEADERS) $(RELEASE_LIBS)
|
||||
ifdef RELEASE_BINS
|
||||
$(NSINSTALL) -t -m 0755 $(RELEASE_BINS) $(DESTDIR)$(bindir)
|
||||
endif
|
||||
ifdef RELEASE_HEADERS
|
||||
$(NSINSTALL) -t -m 0644 $(RELEASE_HEADERS) $(DESTDIR)$(includedir)/$(include_subdir)
|
||||
endif
|
||||
ifdef RELEASE_LIBS
|
||||
$(NSINSTALL) -t -m 0755 $(RELEASE_LIBS) $(DESTDIR)$(libdir)/$(lib_subdir)
|
||||
endif
|
||||
+$(LOOP_OVER_DIRS)
|
||||
|
||||
release:: export
|
||||
ifdef RELEASE_BINS
|
||||
@echo "Copying executable programs and scripts to release directory"
|
||||
@if test -z "$(BUILD_NUMBER)"; then \
|
||||
echo "BUILD_NUMBER must be defined"; \
|
||||
false; \
|
||||
else \
|
||||
true; \
|
||||
fi
|
||||
@if test ! -d $(RELEASE_BIN_DIR); then \
|
||||
rm -rf $(RELEASE_BIN_DIR); \
|
||||
$(NSINSTALL) -D $(RELEASE_BIN_DIR);\
|
||||
else \
|
||||
true; \
|
||||
fi
|
||||
cp $(RELEASE_BINS) $(RELEASE_BIN_DIR)
|
||||
endif
|
||||
ifdef RELEASE_LIBS
|
||||
@echo "Copying libraries to release directory"
|
||||
@if test -z "$(BUILD_NUMBER)"; then \
|
||||
echo "BUILD_NUMBER must be defined"; \
|
||||
false; \
|
||||
else \
|
||||
true; \
|
||||
fi
|
||||
@if test ! -d $(RELEASE_LIBS_DEST); then \
|
||||
rm -rf $(RELEASE_LIBS_DEST); \
|
||||
$(NSINSTALL) -D $(RELEASE_LIBS_DEST);\
|
||||
else \
|
||||
true; \
|
||||
fi
|
||||
cp $(RELEASE_LIBS) $(RELEASE_LIBS_DEST)
|
||||
endif
|
||||
ifdef RELEASE_HEADERS
|
||||
@echo "Copying header files to release directory"
|
||||
@if test -z "$(BUILD_NUMBER)"; then \
|
||||
echo "BUILD_NUMBER must be defined"; \
|
||||
false; \
|
||||
else \
|
||||
true; \
|
||||
fi
|
||||
@if test ! -d $(RELEASE_HEADERS_DEST); then \
|
||||
rm -rf $(RELEASE_HEADERS_DEST); \
|
||||
$(NSINSTALL) -D $(RELEASE_HEADERS_DEST);\
|
||||
else \
|
||||
true; \
|
||||
fi
|
||||
cp $(RELEASE_HEADERS) $(RELEASE_HEADERS_DEST)
|
||||
endif
|
||||
+$(LOOP_OVER_DIRS)
|
||||
|
||||
alltags:
|
||||
rm -f TAGS tags
|
||||
find . -name dist -prune -o \( -name '*.[hc]' -o -name '*.cp' -o -name '*.cpp' \) -print | xargs etags -a
|
||||
find . -name dist -prune -o \( -name '*.[hc]' -o -name '*.cp' -o -name '*.cpp' \) -print | xargs ctags -a
|
||||
|
||||
$(NFSPWD):
|
||||
cd $(@D); $(MAKE) $(@F)
|
||||
|
||||
$(PROGRAM): $(OBJS)
|
||||
@$(MAKE_OBJDIR)
|
||||
ifeq ($(NS_USE_GCC)_$(OS_ARCH),_WINNT)
|
||||
ifdef MOZ_PROFILE_USE
|
||||
# In the second pass, we need to merge the pgc files into the pgd file.
|
||||
# The compiler would do this for us automatically if they were in the right
|
||||
# place, but they're in dist/bin.
|
||||
python $(topsrcdir)/build/win32/pgomerge.py \
|
||||
$(notdir $(PROGRAM:.exe=)) $(DIST)/bin
|
||||
endif # MOZ_PROFILE_USE
|
||||
$(CC) $(OBJS) -Fe$@ -link $(LDFLAGS) $(OS_LIBS) $(EXTRA_LIBS)
|
||||
ifdef MT
|
||||
@if test -f $@.manifest; then \
|
||||
$(MT) -NOLOGO -MANIFEST $@.manifest -OUTPUTRESOURCE:$@\;1; \
|
||||
rm -f $@.manifest; \
|
||||
fi
|
||||
endif # MSVC with manifest tool
|
||||
ifdef MOZ_PROFILE_GENERATE
|
||||
# touch it a few seconds into the future to work around FAT's
|
||||
# 2-second granularity
|
||||
touch -t `date +%Y%m%d%H%M.%S -d "now+5seconds"` pgo.relink
|
||||
endif # MOZ_PROFILE_GENERATE
|
||||
else # WINNT && !GCC
|
||||
$(CC) -o $@ $(CFLAGS) $(OBJS) $(LDFLAGS) $(WRAP_LDFLAGS)
|
||||
endif # WINNT && !GCC
|
||||
ifdef ENABLE_STRIP
|
||||
$(STRIP) $@
|
||||
endif
|
||||
|
||||
$(LIBRARY): $(OBJS)
|
||||
@$(MAKE_OBJDIR)
|
||||
rm -f $@
|
||||
$(AR) $(AR_FLAGS) $(OBJS) $(AR_EXTRA_ARGS)
|
||||
$(RANLIB) $@
|
||||
|
||||
ifeq ($(OS_TARGET), OS2)
|
||||
$(IMPORT_LIBRARY): $(MAPFILE)
|
||||
rm -f $@
|
||||
$(IMPLIB) $@ $(MAPFILE)
|
||||
else
|
||||
ifeq (,$(filter-out WIN95 WINCE WINMO,$(OS_TARGET)))
|
||||
# PDBs and import libraries need to depend on the shared library to
|
||||
# order dependencies properly.
|
||||
$(IMPORT_LIBRARY): $(SHARED_LIBRARY)
|
||||
$(SHARED_LIB_PDB): $(SHARED_LIBRARY)
|
||||
endif
|
||||
endif
|
||||
|
||||
$(SHARED_LIBRARY): $(OBJS) $(RES) $(MAPFILE)
|
||||
@$(MAKE_OBJDIR)
|
||||
rm -f $@
|
||||
ifeq ($(OS_ARCH)$(OS_RELEASE), AIX4.1)
|
||||
echo "#!" > $(OBJDIR)/lib$(LIBRARY_NAME)_syms
|
||||
nm -B -C -g $(OBJS) \
|
||||
| awk '/ [T,D] / {print $$3}' \
|
||||
| sed -e 's/^\.//' \
|
||||
| sort -u >> $(OBJDIR)/lib$(LIBRARY_NAME)_syms
|
||||
$(LD) $(XCFLAGS) -o $@ $(OBJS) -bE:$(OBJDIR)/lib$(LIBRARY_NAME)_syms \
|
||||
-bM:SRE -bnoentry $(OS_LIBS) $(EXTRA_LIBS)
|
||||
else # AIX 4.1
|
||||
ifeq ($(NS_USE_GCC)_$(OS_ARCH),_WINNT)
|
||||
ifdef MOZ_PROFILE_USE
|
||||
python $(topsrcdir)/build/win32/pgomerge.py \
|
||||
$(notdir $(SHARED_LIBRARY:.$(DLL_SUFFIX)=)) $(DIST)/bin
|
||||
endif # MOZ_PROFILE_USE
|
||||
$(LINK_DLL) -MAP $(DLLBASE) $(DLL_LIBS) $(EXTRA_LIBS) $(OBJS) $(RES)
|
||||
ifdef MT
|
||||
@if test -f $@.manifest; then \
|
||||
$(MT) -NOLOGO -MANIFEST $@.manifest -OUTPUTRESOURCE:$@\;2; \
|
||||
rm -f $@.manifest; \
|
||||
fi
|
||||
endif # MSVC with manifest tool
|
||||
ifdef MOZ_PROFILE_GENERATE
|
||||
touch -t `date +%Y%m%d%H%M.%S -d "now+5seconds"` pgo.relink
|
||||
endif # MOZ_PROFILE_GENERATE
|
||||
else # WINNT && !GCC
|
||||
$(MKSHLIB) $(OBJS) $(RES) $(LDFLAGS) $(WRAP_LDFLAGS) $(EXTRA_LIBS)
|
||||
endif # WINNT && !GCC
|
||||
endif # AIX 4.1
|
||||
ifdef ENABLE_STRIP
|
||||
$(STRIP) $@
|
||||
endif
|
||||
|
||||
################################################################################
|
||||
|
||||
ifdef MOZ_PROFILE_USE
|
||||
ifeq ($(NS_USE_GCC)_$(OS_ARCH),_WINNT)
|
||||
# When building with PGO, we have to make sure to re-link
|
||||
# in the MOZ_PROFILE_USE phase if we linked in the
|
||||
# MOZ_PROFILE_GENERATE phase. We'll touch this pgo.relink
|
||||
# file in the link rule in the GENERATE phase to indicate
|
||||
# that we need a relink.
|
||||
$(SHARED_LIBRARY): pgo.relink
|
||||
|
||||
$(PROGRAM): pgo.relink
|
||||
|
||||
endif # WINNT && !GCC
|
||||
endif # MOZ_PROFILE_USE
|
||||
|
||||
ifneq (,$(MOZ_PROFILE_GENERATE)$(MOZ_PROFILE_USE))
|
||||
ifdef NS_USE_GCC
|
||||
# Force rebuilding libraries and programs in both passes because each
|
||||
# pass uses different object files.
|
||||
$(PROGRAM) $(SHARED_LIBRARY) $(LIBRARY): FORCE
|
||||
.PHONY: FORCE
|
||||
endif
|
||||
endif
|
||||
|
||||
################################################################################
|
||||
|
||||
ifdef MOZ_PROFILE_GENERATE
|
||||
# Clean up profiling data during PROFILE_GENERATE phase
|
||||
export::
|
||||
ifeq ($(NS_USE_GCC)_$(OS_ARCH),_WINNT)
|
||||
$(foreach pgd,$(wildcard *.pgd),pgomgr -clear $(pgd);)
|
||||
else
|
||||
ifdef NS_USE_GCC
|
||||
-$(RM) *.gcda
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
################################################################################
|
||||
|
||||
ifeq ($(OS_ARCH),WINNT)
|
||||
$(RES): $(RESNAME)
|
||||
@$(MAKE_OBJDIR)
|
||||
# The resource compiler does not understand the -U option.
|
||||
ifdef NS_USE_GCC
|
||||
$(RC) $(RCFLAGS) $(filter-out -U%,$(DEFINES)) $(INCLUDES:-I%=--include-dir %) -o $@ $<
|
||||
else
|
||||
$(RC) $(RCFLAGS) $(filter-out -U%,$(DEFINES)) $(INCLUDES) -Fo$@ $<
|
||||
endif # GCC
|
||||
@echo $(RES) finished
|
||||
endif
|
||||
|
||||
$(MAPFILE): $(LIBRARY_NAME).def
|
||||
@$(MAKE_OBJDIR)
|
||||
ifeq ($(OS_ARCH),SunOS)
|
||||
grep -v ';-' $< | \
|
||||
sed -e 's,;+,,' -e 's; DATA ;;' -e 's,;;,,' -e 's,;.*,;,' > $@
|
||||
endif
|
||||
ifeq ($(OS_ARCH),OS2)
|
||||
echo LIBRARY $(LIBRARY_NAME)$(LIBRARY_VERSION) INITINSTANCE TERMINSTANCE > $@
|
||||
echo PROTMODE >> $@
|
||||
echo CODE LOADONCALL MOVEABLE DISCARDABLE >> $@
|
||||
echo DATA PRELOAD MOVEABLE MULTIPLE NONSHARED >> $@
|
||||
echo EXPORTS >> $@
|
||||
grep -v ';+' $< | grep -v ';-' | \
|
||||
sed -e 's; DATA ;;' -e 's,;;,,' -e 's,;.*,,' -e 's,\([\t ]*\),\1_,' | \
|
||||
awk 'BEGIN {ord=1;} { print($$0 " @" ord " RESIDENTNAME"); ord++;}' >> $@
|
||||
$(ADD_TO_DEF_FILE)
|
||||
endif
|
||||
|
||||
#
|
||||
# Translate source filenames to absolute paths. This is required for
|
||||
# debuggers under Windows and OS/2 to find source files automatically.
|
||||
#
|
||||
|
||||
ifeq (,$(filter-out AIX OS2,$(OS_ARCH)))
|
||||
NEED_ABSOLUTE_PATH = 1
|
||||
endif
|
||||
|
||||
ifeq ($(NS_USE_GCC)_$(OS_ARCH),_WINNT)
|
||||
NEED_ABSOLUTE_PATH = 1
|
||||
endif
|
||||
|
||||
ifdef NEED_ABSOLUTE_PATH
|
||||
# The quotes allow absolute paths to contain spaces.
|
||||
pr_abspath = "$(if $(findstring :,$(1)),$(1),$(if $(filter /%,$(1)),$(1),$(CURDIR)/$(1)))"
|
||||
endif
|
||||
|
||||
$(OBJDIR)/%.$(OBJ_SUFFIX): %.cpp
|
||||
@$(MAKE_OBJDIR)
|
||||
ifeq ($(NS_USE_GCC)_$(OS_ARCH),_WINNT)
|
||||
$(CCC) -Fo$@ -c $(CCCFLAGS) $(call pr_abspath,$<)
|
||||
else
|
||||
ifeq ($(NS_USE_GCC)_$(OS_ARCH),_WINCE)
|
||||
$(CCC) -Fo$@ -c $(CCCFLAGS) $<
|
||||
else
|
||||
ifdef NEED_ABSOLUTE_PATH
|
||||
$(CCC) -o $@ -c $(CCCFLAGS) $(call pr_abspath,$<)
|
||||
else
|
||||
$(CCC) -o $@ -c $(CCCFLAGS) $<
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
WCCFLAGS1 = $(subst /,\\,$(CFLAGS))
|
||||
WCCFLAGS2 = $(subst -I,-i=,$(WCCFLAGS1))
|
||||
WCCFLAGS3 = $(subst -D,-d,$(WCCFLAGS2))
|
||||
$(OBJDIR)/%.$(OBJ_SUFFIX): %.c
|
||||
@$(MAKE_OBJDIR)
|
||||
ifeq ($(NS_USE_GCC)_$(OS_ARCH),_WINNT)
|
||||
$(CC) -Fo$@ -c $(CFLAGS) $(call pr_abspath,$<)
|
||||
else
|
||||
ifeq ($(NS_USE_GCC)_$(OS_ARCH),_WINCE)
|
||||
$(CC) -Fo$@ -c $(CFLAGS) $<
|
||||
else
|
||||
ifdef NEED_ABSOLUTE_PATH
|
||||
$(CC) -o $@ -c $(CFLAGS) $(call pr_abspath,$<)
|
||||
else
|
||||
$(CC) -o $@ -c $(CFLAGS) $<
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
|
||||
$(OBJDIR)/%.$(OBJ_SUFFIX): %.s
|
||||
@$(MAKE_OBJDIR)
|
||||
$(AS) -o $@ $(ASFLAGS) -c $<
|
||||
|
||||
%.i: %.c
|
||||
$(CC) -C -E $(CFLAGS) $< > $*.i
|
||||
|
||||
%: %.pl
|
||||
rm -f $@; cp $< $@; chmod +x $@
|
||||
|
||||
#
|
||||
# HACK ALERT
|
||||
#
|
||||
# The only purpose of this rule is to pass Mozilla's Tinderbox depend
|
||||
# builds (http://tinderbox.mozilla.org/showbuilds.cgi). Mozilla's
|
||||
# Tinderbox builds NSPR continuously as part of the Mozilla client.
|
||||
# Because NSPR's make depend is not implemented, whenever we change
|
||||
# an NSPR header file, the depend build does not recompile the NSPR
|
||||
# files that depend on the header.
|
||||
#
|
||||
# This rule makes all the objects depend on a dummy header file.
|
||||
# Touch this dummy header file to force the depend build to recompile
|
||||
# everything.
|
||||
#
|
||||
# This rule should be removed when make depend is implemented.
|
||||
#
|
||||
|
||||
DUMMY_DEPEND_H = $(topsrcdir)/config/prdepend.h
|
||||
|
||||
$(filter $(OBJDIR)/%.$(OBJ_SUFFIX),$(OBJS)): $(OBJDIR)/%.$(OBJ_SUFFIX): $(DUMMY_DEPEND_H)
|
||||
|
||||
# END OF HACK
|
||||
|
||||
################################################################################
|
||||
# Special gmake rules.
|
||||
################################################################################
|
||||
|
||||
#
|
||||
# Disallow parallel builds with MSVC < 8 since it can't open the PDB file in
|
||||
# parallel.
|
||||
#
|
||||
ifeq (,$(filter-out 1200 1300 1310,$(MSC_VER)))
|
||||
.NOTPARALLEL:
|
||||
endif
|
||||
|
||||
#
|
||||
# Re-define the list of default suffixes, so gmake won't have to churn through
|
||||
# hundreds of built-in suffix rules for stuff we don't need.
|
||||
#
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: .a .$(OBJ_SUFFIX) .c .cpp .s .h .i .pl
|
||||
|
||||
#
|
||||
# Fake targets. Always run these rules, even if a file/directory with that
|
||||
# name already exists.
|
||||
#
|
||||
.PHONY: all alltags clean export install libs realclean release
|
||||
|
||||
#
|
||||
# List the target pattern of an implicit rule as a dependency of the
|
||||
# special target .PRECIOUS to preserve intermediate files made by
|
||||
# implicit rules whose target patterns match that file's name.
|
||||
# (See GNU Make documentation, Edition 0.51, May 1996, Sec. 10.4,
|
||||
# p. 107.)
|
||||
#
|
||||
.PRECIOUS: $(OBJDIR)/%.$(OBJ_SUFFIX)
|
||||
172
nsprpub/config/system-headers
Normal file
172
nsprpub/config/system-headers
Normal file
|
|
@ -0,0 +1,172 @@
|
|||
Aliases.h
|
||||
arpa/inet.h
|
||||
assert.h
|
||||
bsd/libc.h
|
||||
bsd/syscall.h
|
||||
bstring.h
|
||||
builtin.h
|
||||
c_asm.h
|
||||
cf.h
|
||||
CFBundle.h
|
||||
CFData.h
|
||||
CFDictionary.h
|
||||
CFString.h
|
||||
CFURL.h
|
||||
CodeFragments.h
|
||||
commdlg.h
|
||||
crt_externs.h
|
||||
crypt.h
|
||||
ctype.h
|
||||
descrip.h
|
||||
Devices.h
|
||||
direct.h
|
||||
dirent.h
|
||||
dlfcn.h
|
||||
dl.h
|
||||
DriverServices.h
|
||||
dvidef.h
|
||||
errno.h
|
||||
Errors.h
|
||||
Events.h
|
||||
fcntl.h
|
||||
fibdef.h
|
||||
files.h
|
||||
Files.h
|
||||
float.h
|
||||
Folders.h
|
||||
Gestalt.h
|
||||
getopt.h
|
||||
grp.h
|
||||
ia64/sys/inline.h
|
||||
ifaddrs.h
|
||||
image.h
|
||||
ints.h
|
||||
iodef.h
|
||||
io.h
|
||||
iostream.h
|
||||
kernel/OS.h
|
||||
lib$routines.h
|
||||
limits.h
|
||||
loader.h
|
||||
locale.h
|
||||
LowMem.h
|
||||
MacErrors.h
|
||||
machine/builtins.h
|
||||
machine/clock.h
|
||||
machine/endian.h
|
||||
machine/inline.h
|
||||
mach/mach_init.h
|
||||
mach/mach_host.h
|
||||
mach-o/dyld.h
|
||||
MacTypes.h
|
||||
Math64.h
|
||||
math.h
|
||||
mbstring.h
|
||||
memory.h
|
||||
MixedMode.h
|
||||
model.h
|
||||
mswsock.h
|
||||
Multiprocessing.h
|
||||
mutex.h
|
||||
netdb.h
|
||||
net/if.h
|
||||
netinet/in.h
|
||||
netinet/in_systm.h
|
||||
netinet/tcp.h
|
||||
OpenTptInternet.h
|
||||
OpenTransport.h
|
||||
os2.h
|
||||
OS.h
|
||||
osreldate.h
|
||||
OSUtils.h
|
||||
poll.h
|
||||
PPCToolbox.h
|
||||
Processes.h
|
||||
process.h
|
||||
pthread.h
|
||||
pwd.h
|
||||
QDOffscreen.h
|
||||
Resources.h
|
||||
rld_interface.h
|
||||
rpc/types.h
|
||||
semaphore.h
|
||||
setjmp.h
|
||||
share.h
|
||||
signal.h
|
||||
ssdef.h
|
||||
starlet.h
|
||||
stat.h
|
||||
stdarg.h
|
||||
stddef.h
|
||||
stdio.h
|
||||
stdlib.h
|
||||
string.h
|
||||
stropts.h
|
||||
stsdef.h
|
||||
support/SupportDefs.h
|
||||
support/TLS.h
|
||||
synch.h
|
||||
sys/atomic_op.h
|
||||
syscall.h
|
||||
sys/cfgodm.h
|
||||
sys/file.h
|
||||
sys/filio.h
|
||||
sys/immu.h
|
||||
sys/ioctl.h
|
||||
sys/ipc.h
|
||||
sys/ldr.h
|
||||
sys/locking.h
|
||||
sys/lwp.h
|
||||
sys/mman.h
|
||||
sys/mpctl.h
|
||||
sys/param.h
|
||||
sys/pda.h
|
||||
sys/poll.h
|
||||
sys/prctl.h
|
||||
sys/priv.h
|
||||
sys/procfs.h
|
||||
sys/pstat.h
|
||||
sys/regset.h
|
||||
sys/resource.h
|
||||
sys/sched.h
|
||||
sys/select.h
|
||||
sys/sem.h
|
||||
sys/sendfile.h
|
||||
sys/shm.h
|
||||
sys/socket.h
|
||||
sys/stack.h
|
||||
sys/stat.h
|
||||
sys/statvfs.h
|
||||
sys/syscall.h
|
||||
sys/sysctl.h
|
||||
sys/sysmp.h
|
||||
sys/syssgi.h
|
||||
sys/systeminfo.h
|
||||
sys/timeb.h
|
||||
sys/time.h
|
||||
sys/times.h
|
||||
sys/types.h
|
||||
sys/ucontext.h
|
||||
sys/uio.h
|
||||
sys/utsname.h
|
||||
sys/wait.h
|
||||
task.h
|
||||
TextUtils.h
|
||||
thread.h
|
||||
time.h
|
||||
Timer.h
|
||||
types.h
|
||||
Types.h
|
||||
ucontext.h
|
||||
ucx$inetdef.h
|
||||
ulocks.h
|
||||
unistd.h
|
||||
unix.h
|
||||
unixlib.h
|
||||
utime.h
|
||||
wchar.h
|
||||
winbase.h
|
||||
win/compobj.h
|
||||
windef.h
|
||||
windows.h
|
||||
winsock.h
|
||||
9931
nsprpub/configure
vendored
Normal file
9931
nsprpub/configure
vendored
Normal file
File diff suppressed because it is too large
Load diff
3176
nsprpub/configure.in
Normal file
3176
nsprpub/configure.in
Normal file
File diff suppressed because it is too large
Load diff
1
nsprpub/lib/.cvsignore
Normal file
1
nsprpub/lib/.cvsignore
Normal file
|
|
@ -0,0 +1 @@
|
|||
Makefile
|
||||
24
nsprpub/lib/Makefile.in
Normal file
24
nsprpub/lib/Makefile.in
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
#
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
#! gmake
|
||||
|
||||
MOD_DEPTH = ..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(MOD_DEPTH)/config/autoconf.mk
|
||||
|
||||
export NSPR20=1
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
DIRS = ds libc
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
export:: $(TARGETS)
|
||||
|
||||
2
nsprpub/lib/ds/.cvsignore
Normal file
2
nsprpub/lib/ds/.cvsignore
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
Makefile
|
||||
_pl_bld.h
|
||||
151
nsprpub/lib/ds/Makefile.in
Normal file
151
nsprpub/lib/ds/Makefile.in
Normal file
|
|
@ -0,0 +1,151 @@
|
|||
#
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
#! gmake
|
||||
|
||||
MOD_DEPTH = ../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(MOD_DEPTH)/config/autoconf.mk
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
INCLUDES = -I$(dist_includedir) -I$(topsrcdir)/pr/include
|
||||
|
||||
CSRCS = \
|
||||
plarena.c \
|
||||
plhash.c \
|
||||
plvrsion.c \
|
||||
$(NULL)
|
||||
|
||||
HEADERS = \
|
||||
plarenas.h \
|
||||
plarena.h \
|
||||
plhash.h \
|
||||
$(NULL)
|
||||
|
||||
HEADERS := $(addprefix $(srcdir)/, $(HEADERS))
|
||||
|
||||
ifeq ($(OS_ARCH), WINNT)
|
||||
RES=$(OBJDIR)/plds.res
|
||||
RESNAME=plds.rc
|
||||
endif # WINNT
|
||||
|
||||
ifeq ($(OS_ARCH), AIX)
|
||||
ifeq ($(CLASSIC_NSPR),1)
|
||||
OS_LIBS = -lc
|
||||
else
|
||||
OS_LIBS = -lc_r
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(OS_ARCH),IRIX)
|
||||
OS_LIBS = -lc
|
||||
endif
|
||||
|
||||
ifeq ($(OS_ARCH),SunOS)
|
||||
OS_LIBS = -lc
|
||||
MAPFILE = $(OBJDIR)/pldsmap.sun
|
||||
GARBAGE += $(MAPFILE)
|
||||
ifdef NS_USE_GCC
|
||||
ifdef GCC_USE_GNU_LD
|
||||
MKSHLIB += -Wl,--version-script,$(MAPFILE)
|
||||
else
|
||||
MKSHLIB += -Wl,-M,$(MAPFILE)
|
||||
endif
|
||||
else
|
||||
MKSHLIB += -M $(MAPFILE)
|
||||
endif
|
||||
# The -R '$ORIGIN' linker option instructs this library to search for its
|
||||
# dependencies in the same directory where it resides.
|
||||
MKSHLIB += -R '$$ORIGIN'
|
||||
endif
|
||||
|
||||
ifeq ($(OS_ARCH),OS2)
|
||||
MAPFILE = $(OBJDIR)/$(LIBRARY_NAME)$(LIBRARY_VERSION).def
|
||||
GARBAGE += $(MAPFILE)
|
||||
MKSHLIB += $(MAPFILE)
|
||||
endif
|
||||
|
||||
EXTRA_LIBS = $(LIBNSPR)
|
||||
|
||||
# On SCOOS, we can't link with extra libraries when
|
||||
# we build a shared library. If we do so, the linker doesn't
|
||||
# complain, but we would run into weird problems at run-time.
|
||||
# Therefore on these platforms, we link just the .o files.
|
||||
ifeq ($(OS_ARCH),SCOOS)
|
||||
EXTRA_LIBS =
|
||||
endif
|
||||
|
||||
ifdef RESOLVE_LINK_SYMBOLS
|
||||
EXTRA_LIBS += $(OS_LIBS)
|
||||
endif
|
||||
|
||||
LIBRARY_NAME = plds
|
||||
LIBRARY_VERSION = $(MOD_MAJOR_VERSION)
|
||||
|
||||
RELEASE_HEADERS = $(HEADERS)
|
||||
RELEASE_HEADERS_DEST = $(RELEASE_INCLUDE_DIR)
|
||||
RELEASE_LIBS = $(TARGETS)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
#
|
||||
# Version information generation (begin)
|
||||
#
|
||||
ECHO = echo
|
||||
TINC = $(OBJDIR)/_pl_bld.h
|
||||
PROD = $(notdir $(SHARED_LIBRARY))
|
||||
NOW = $(MOD_DEPTH)/config/$(OBJDIR)/now
|
||||
SH_DATE = $(shell date "+%Y-%m-%d %T")
|
||||
SH_NOW = $(shell $(NOW))
|
||||
|
||||
ifeq ($(NS_USE_GCC)_$(OS_ARCH),_WINNT)
|
||||
SUF = i64
|
||||
else
|
||||
SUF = LL
|
||||
endif
|
||||
|
||||
GARBAGE += $(TINC)
|
||||
|
||||
$(TINC):
|
||||
@$(MAKE_OBJDIR)
|
||||
@$(ECHO) '#define _BUILD_STRING "$(SH_DATE)"' > $(TINC)
|
||||
@if test ! -z "$(SH_NOW)"; then \
|
||||
$(ECHO) '#define _BUILD_TIME $(SH_NOW)$(SUF)' >> $(TINC); \
|
||||
else \
|
||||
true; \
|
||||
fi
|
||||
@$(ECHO) '#define _PRODUCTION "$(PROD)"' >> $(TINC)
|
||||
|
||||
|
||||
$(OBJDIR)/plvrsion.$(OBJ_SUFFIX): plvrsion.c $(TINC)
|
||||
ifeq ($(NS_USE_GCC)_$(OS_ARCH),_WINNT)
|
||||
$(CC) -Fo$@ -c $(CFLAGS) -I$(OBJDIR) $<
|
||||
else
|
||||
$(CC) -o $@ -c $(CFLAGS) -I$(OBJDIR) $<
|
||||
endif
|
||||
#
|
||||
# Version information generation (end)
|
||||
#
|
||||
|
||||
#
|
||||
# The Client build wants the shared libraries in $(dist_bindir),
|
||||
# so we also install them there.
|
||||
#
|
||||
|
||||
export:: $(TARGETS)
|
||||
$(INSTALL) -m 444 $(HEADERS) $(dist_includedir)
|
||||
$(INSTALL) -m 444 $(TARGETS) $(dist_libdir)
|
||||
ifdef SHARED_LIBRARY
|
||||
ifeq ($(OS_ARCH),HP-UX)
|
||||
$(INSTALL) -m 755 $(SHARED_LIBRARY) $(dist_libdir)
|
||||
$(INSTALL) -m 755 $(SHARED_LIBRARY) $(dist_bindir)
|
||||
else
|
||||
$(INSTALL) -m 444 $(SHARED_LIBRARY) $(dist_bindir)
|
||||
endif
|
||||
endif
|
||||
334
nsprpub/lib/ds/plarena.c
Normal file
334
nsprpub/lib/ds/plarena.c
Normal file
|
|
@ -0,0 +1,334 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
/*
|
||||
* Lifetime-based fast allocation, inspired by much prior art, including
|
||||
* "Fast Allocation and Deallocation of Memory Based on Object Lifetimes"
|
||||
* David R. Hanson, Software -- Practice and Experience, Vol. 20(1).
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "plarena.h"
|
||||
#include "prmem.h"
|
||||
#include "prbit.h"
|
||||
#include "prlog.h"
|
||||
#include "prlock.h"
|
||||
#include "prinit.h"
|
||||
|
||||
#ifdef PL_ARENAMETER
|
||||
static PLArenaStats *arena_stats_list;
|
||||
|
||||
#define COUNT(pool,what) (pool)->stats.what++
|
||||
#else
|
||||
#define COUNT(pool,what) /* nothing */
|
||||
#endif
|
||||
|
||||
#define PL_ARENA_DEFAULT_ALIGN sizeof(double)
|
||||
|
||||
PR_IMPLEMENT(void) PL_InitArenaPool(
|
||||
PLArenaPool *pool, const char *name, PRUint32 size, PRUint32 align)
|
||||
{
|
||||
/*
|
||||
* Look-up table of PR_BITMASK(PR_CeilingLog2(align)) values for
|
||||
* align = 1 to 32.
|
||||
*/
|
||||
static const PRUint8 pmasks[33] = {
|
||||
0, /* not used */
|
||||
0, 1, 3, 3, 7, 7, 7, 7,15,15,15,15,15,15,15,15, /* 1 ... 16 */
|
||||
31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31}; /* 17 ... 32 */
|
||||
|
||||
if (align == 0)
|
||||
align = PL_ARENA_DEFAULT_ALIGN;
|
||||
|
||||
if (align < sizeof(pmasks)/sizeof(pmasks[0]))
|
||||
pool->mask = pmasks[align];
|
||||
else
|
||||
pool->mask = PR_BITMASK(PR_CeilingLog2(align));
|
||||
|
||||
pool->first.next = NULL;
|
||||
/* Set all three addresses in pool->first to the same dummy value.
|
||||
* These addresses are only compared with each other, but never
|
||||
* dereferenced. */
|
||||
pool->first.base = pool->first.avail = pool->first.limit =
|
||||
(PRUword)PL_ARENA_ALIGN(pool, &pool->first + 1);
|
||||
pool->current = &pool->first;
|
||||
/*
|
||||
* Compute the net size so that each arena's gross size is |size|.
|
||||
* sizeof(PLArena) + pool->mask is the header and alignment slop
|
||||
* that PL_ArenaAllocate adds to the net size.
|
||||
*/
|
||||
if (size > sizeof(PLArena) + pool->mask)
|
||||
pool->arenasize = size - (sizeof(PLArena) + pool->mask);
|
||||
else
|
||||
pool->arenasize = size;
|
||||
#ifdef PL_ARENAMETER
|
||||
memset(&pool->stats, 0, sizeof pool->stats);
|
||||
pool->stats.name = strdup(name);
|
||||
pool->stats.next = arena_stats_list;
|
||||
arena_stats_list = &pool->stats;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** PL_ArenaAllocate() -- allocate space from an arena pool
|
||||
**
|
||||
** Description: PL_ArenaAllocate() allocates space from an arena
|
||||
** pool.
|
||||
**
|
||||
** First, try to satisfy the request from arenas starting at
|
||||
** pool->current. Then try to allocate a new arena from the heap.
|
||||
**
|
||||
** Returns: pointer to allocated space or NULL
|
||||
**
|
||||
** Notes: The original implementation had some difficult to
|
||||
** solve bugs; the code was difficult to read. Sometimes it's
|
||||
** just easier to rewrite it. I did that. larryh.
|
||||
**
|
||||
** See also: bugzilla: 45343.
|
||||
**
|
||||
*/
|
||||
|
||||
PR_IMPLEMENT(void *) PL_ArenaAllocate(PLArenaPool *pool, PRUint32 nb)
|
||||
{
|
||||
PLArena *a;
|
||||
char *rp; /* returned pointer */
|
||||
PRUint32 nbOld;
|
||||
|
||||
PR_ASSERT((nb & pool->mask) == 0);
|
||||
|
||||
nbOld = nb;
|
||||
nb = (PRUword)PL_ARENA_ALIGN(pool, nb); /* force alignment */
|
||||
if (nb < nbOld)
|
||||
return NULL;
|
||||
|
||||
/* attempt to allocate from arenas at pool->current */
|
||||
{
|
||||
a = pool->current;
|
||||
do {
|
||||
if ( nb <= a->limit - a->avail ) {
|
||||
pool->current = a;
|
||||
rp = (char *)a->avail;
|
||||
a->avail += nb;
|
||||
return rp;
|
||||
}
|
||||
} while( NULL != (a = a->next) );
|
||||
}
|
||||
|
||||
/* attempt to allocate from the heap */
|
||||
{
|
||||
PRUint32 sz = PR_MAX(pool->arenasize, nb);
|
||||
if (PR_UINT32_MAX - sz < sizeof *a + pool->mask) {
|
||||
a = NULL;
|
||||
} else {
|
||||
sz += sizeof *a + pool->mask; /* header and alignment slop */
|
||||
a = (PLArena*)PR_MALLOC(sz);
|
||||
}
|
||||
if ( NULL != a ) {
|
||||
a->limit = (PRUword)a + sz;
|
||||
a->base = a->avail = (PRUword)PL_ARENA_ALIGN(pool, a + 1);
|
||||
PL_MAKE_MEM_NOACCESS((void*)a->avail, a->limit - a->avail);
|
||||
rp = (char *)a->avail;
|
||||
a->avail += nb;
|
||||
PR_ASSERT(a->avail <= a->limit);
|
||||
/* the newly allocated arena is linked after pool->current
|
||||
* and becomes pool->current */
|
||||
a->next = pool->current->next;
|
||||
pool->current->next = a;
|
||||
pool->current = a;
|
||||
if ( NULL == pool->first.next )
|
||||
pool->first.next = a;
|
||||
PL_COUNT_ARENA(pool,++);
|
||||
COUNT(pool, nmallocs);
|
||||
return(rp);
|
||||
}
|
||||
}
|
||||
|
||||
/* we got to here, and there's no memory to allocate */
|
||||
return(NULL);
|
||||
} /* --- end PL_ArenaAllocate() --- */
|
||||
|
||||
PR_IMPLEMENT(void *) PL_ArenaGrow(
|
||||
PLArenaPool *pool, void *p, PRUint32 size, PRUint32 incr)
|
||||
{
|
||||
void *newp;
|
||||
|
||||
if (PR_UINT32_MAX - size < incr)
|
||||
return NULL;
|
||||
PL_ARENA_ALLOCATE(newp, pool, size + incr);
|
||||
if (newp)
|
||||
memcpy(newp, p, size);
|
||||
return newp;
|
||||
}
|
||||
|
||||
PR_IMPLEMENT(void) PL_ClearArenaPool(PLArenaPool *pool, PRInt32 pattern)
|
||||
{
|
||||
PLArena *a;
|
||||
|
||||
for (a = pool->first.next; a; a = a->next) {
|
||||
PR_ASSERT(a->base <= a->avail && a->avail <= a->limit);
|
||||
a->avail = a->base;
|
||||
PL_CLEAR_UNUSED_PATTERN(a, pattern);
|
||||
PL_MAKE_MEM_NOACCESS((void*)a->avail, a->limit - a->avail);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Free tail arenas linked after head, which may not be the true list head.
|
||||
* Reset pool->current to point to head in case it pointed at a tail arena.
|
||||
*/
|
||||
static void FreeArenaList(PLArenaPool *pool, PLArena *head)
|
||||
{
|
||||
PLArena *a = head->next;
|
||||
if (!a)
|
||||
return;
|
||||
|
||||
head->next = NULL;
|
||||
|
||||
do {
|
||||
PLArena *tmp = a;
|
||||
a = a->next;
|
||||
PL_CLEAR_ARENA(tmp);
|
||||
PL_COUNT_ARENA(pool,--);
|
||||
PR_DELETE(tmp);
|
||||
} while (a);
|
||||
|
||||
pool->current = head;
|
||||
}
|
||||
|
||||
PR_IMPLEMENT(void) PL_ArenaRelease(PLArenaPool *pool, char *mark)
|
||||
{
|
||||
PLArena *a;
|
||||
|
||||
for (a = &pool->first; a; a = a->next) {
|
||||
if (PR_UPTRDIFF(mark, a->base) <= PR_UPTRDIFF(a->avail, a->base)) {
|
||||
a->avail = (PRUword)PL_ARENA_ALIGN(pool, mark);
|
||||
FreeArenaList(pool, a);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PR_IMPLEMENT(void) PL_FreeArenaPool(PLArenaPool *pool)
|
||||
{
|
||||
FreeArenaList(pool, &pool->first);
|
||||
COUNT(pool, ndeallocs);
|
||||
}
|
||||
|
||||
PR_IMPLEMENT(void) PL_FinishArenaPool(PLArenaPool *pool)
|
||||
{
|
||||
FreeArenaList(pool, &pool->first);
|
||||
#ifdef PL_ARENAMETER
|
||||
{
|
||||
PLArenaStats *stats, **statsp;
|
||||
|
||||
if (pool->stats.name)
|
||||
PR_DELETE(pool->stats.name);
|
||||
for (statsp = &arena_stats_list; (stats = *statsp) != 0;
|
||||
statsp = &stats->next) {
|
||||
if (stats == &pool->stats) {
|
||||
*statsp = stats->next;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
PR_IMPLEMENT(void) PL_CompactArenaPool(PLArenaPool *ap)
|
||||
{
|
||||
}
|
||||
|
||||
PR_IMPLEMENT(void) PL_ArenaFinish(void)
|
||||
{
|
||||
}
|
||||
|
||||
PR_IMPLEMENT(size_t) PL_SizeOfArenaPoolExcludingPool(
|
||||
const PLArenaPool *pool, PLMallocSizeFn mallocSizeOf)
|
||||
{
|
||||
/*
|
||||
* The first PLArena is within |pool|, so don't measure it. Subsequent
|
||||
* PLArenas are separate and must be measured.
|
||||
*/
|
||||
size_t size = 0;
|
||||
const PLArena *arena = pool->first.next;
|
||||
while (arena) {
|
||||
size += mallocSizeOf(arena);
|
||||
arena = arena->next;
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
#ifdef PL_ARENAMETER
|
||||
PR_IMPLEMENT(void) PL_ArenaCountAllocation(PLArenaPool *pool, PRUint32 nb)
|
||||
{
|
||||
pool->stats.nallocs++;
|
||||
pool->stats.nbytes += nb;
|
||||
if (nb > pool->stats.maxalloc)
|
||||
pool->stats.maxalloc = nb;
|
||||
pool->stats.variance += nb * nb;
|
||||
}
|
||||
|
||||
PR_IMPLEMENT(void) PL_ArenaCountInplaceGrowth(
|
||||
PLArenaPool *pool, PRUint32 size, PRUint32 incr)
|
||||
{
|
||||
pool->stats.ninplace++;
|
||||
}
|
||||
|
||||
PR_IMPLEMENT(void) PL_ArenaCountGrowth(
|
||||
PLArenaPool *pool, PRUint32 size, PRUint32 incr)
|
||||
{
|
||||
pool->stats.ngrows++;
|
||||
pool->stats.nbytes += incr;
|
||||
pool->stats.variance -= size * size;
|
||||
size += incr;
|
||||
if (size > pool->stats.maxalloc)
|
||||
pool->stats.maxalloc = size;
|
||||
pool->stats.variance += size * size;
|
||||
}
|
||||
|
||||
PR_IMPLEMENT(void) PL_ArenaCountRelease(PLArenaPool *pool, char *mark)
|
||||
{
|
||||
pool->stats.nreleases++;
|
||||
}
|
||||
|
||||
PR_IMPLEMENT(void) PL_ArenaCountRetract(PLArenaPool *pool, char *mark)
|
||||
{
|
||||
pool->stats.nfastrels++;
|
||||
}
|
||||
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
|
||||
PR_IMPLEMENT(void) PL_DumpArenaStats(FILE *fp)
|
||||
{
|
||||
PLArenaStats *stats;
|
||||
double mean, variance;
|
||||
|
||||
for (stats = arena_stats_list; stats; stats = stats->next) {
|
||||
if (stats->nallocs != 0) {
|
||||
mean = (double)stats->nbytes / stats->nallocs;
|
||||
variance = fabs(stats->variance / stats->nallocs - mean * mean);
|
||||
} else {
|
||||
mean = variance = 0;
|
||||
}
|
||||
|
||||
fprintf(fp, "\n%s allocation statistics:\n", stats->name);
|
||||
fprintf(fp, " number of arenas: %u\n", stats->narenas);
|
||||
fprintf(fp, " number of allocations: %u\n", stats->nallocs);
|
||||
fprintf(fp, " number of free arena reclaims: %u\n", stats->nreclaims);
|
||||
fprintf(fp, " number of malloc calls: %u\n", stats->nmallocs);
|
||||
fprintf(fp, " number of deallocations: %u\n", stats->ndeallocs);
|
||||
fprintf(fp, " number of allocation growths: %u\n", stats->ngrows);
|
||||
fprintf(fp, " number of in-place growths: %u\n", stats->ninplace);
|
||||
fprintf(fp, "number of released allocations: %u\n", stats->nreleases);
|
||||
fprintf(fp, " number of fast releases: %u\n", stats->nfastrels);
|
||||
fprintf(fp, " total bytes allocated: %u\n", stats->nbytes);
|
||||
fprintf(fp, " mean allocation size: %g\n", mean);
|
||||
fprintf(fp, " standard deviation: %g\n", sqrt(variance));
|
||||
fprintf(fp, " maximum allocation size: %u\n", stats->maxalloc);
|
||||
}
|
||||
}
|
||||
#endif /* PL_ARENAMETER */
|
||||
327
nsprpub/lib/ds/plarena.h
Normal file
327
nsprpub/lib/ds/plarena.h
Normal file
|
|
@ -0,0 +1,327 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef plarena_h___
|
||||
#define plarena_h___
|
||||
/*
|
||||
* Lifetime-based fast allocation, inspired by much prior art, including
|
||||
* "Fast Allocation and Deallocation of Memory Based on Object Lifetimes"
|
||||
* David R. Hanson, Software -- Practice and Experience, Vol. 20(1).
|
||||
*
|
||||
* Also supports LIFO allocation (PL_ARENA_MARK/PL_ARENA_RELEASE).
|
||||
*/
|
||||
#include "prtypes.h"
|
||||
|
||||
PR_BEGIN_EXTERN_C
|
||||
|
||||
typedef struct PLArena PLArena;
|
||||
|
||||
struct PLArena {
|
||||
PLArena *next; /* next arena for this lifetime */
|
||||
PRUword base; /* aligned base address, follows this header */
|
||||
PRUword limit; /* one beyond last byte in arena */
|
||||
PRUword avail; /* points to next available byte */
|
||||
};
|
||||
|
||||
#ifdef PL_ARENAMETER
|
||||
typedef struct PLArenaStats PLArenaStats;
|
||||
|
||||
struct PLArenaStats {
|
||||
PLArenaStats *next; /* next in arenaStats list */
|
||||
char *name; /* name for debugging */
|
||||
PRUint32 narenas; /* number of arenas in pool */
|
||||
PRUint32 nallocs; /* number of PL_ARENA_ALLOCATE() calls */
|
||||
PRUint32 nreclaims; /* number of reclaims from freeArenas */
|
||||
PRUint32 nmallocs; /* number of malloc() calls */
|
||||
PRUint32 ndeallocs; /* number of lifetime deallocations */
|
||||
PRUint32 ngrows; /* number of PL_ARENA_GROW() calls */
|
||||
PRUint32 ninplace; /* number of in-place growths */
|
||||
PRUint32 nreleases; /* number of PL_ARENA_RELEASE() calls */
|
||||
PRUint32 nfastrels; /* number of "fast path" releases */
|
||||
PRUint32 nbytes; /* total bytes allocated */
|
||||
PRUint32 maxalloc; /* maximum allocation size in bytes */
|
||||
PRFloat64 variance; /* size variance accumulator */
|
||||
};
|
||||
#endif
|
||||
|
||||
typedef struct PLArenaPool PLArenaPool;
|
||||
|
||||
struct PLArenaPool {
|
||||
PLArena first; /* first arena in pool list */
|
||||
PLArena *current; /* arena from which to allocate space */
|
||||
PRUint32 arenasize; /* net exact size of a new arena */
|
||||
PRUword mask; /* alignment mask (power-of-2 - 1) */
|
||||
#ifdef PL_ARENAMETER
|
||||
PLArenaStats stats;
|
||||
#endif
|
||||
};
|
||||
|
||||
/*
|
||||
* WARNING: The PL_MAKE_MEM_ macros are for internal use by NSPR. Do NOT use
|
||||
* them in your code.
|
||||
*
|
||||
* NOTE: Valgrind support to be added.
|
||||
*
|
||||
* The PL_MAKE_MEM_ macros are modeled after the MOZ_MAKE_MEM_ macros in
|
||||
* Mozilla's mfbt/MemoryChecking.h. Only AddressSanitizer is supported now.
|
||||
*
|
||||
* Provides a common interface to the ASan (AddressSanitizer) and Valgrind
|
||||
* functions used to mark memory in certain ways. In detail, the following
|
||||
* three macros are provided:
|
||||
*
|
||||
* PL_MAKE_MEM_NOACCESS - Mark memory as unsafe to access (e.g. freed)
|
||||
* PL_MAKE_MEM_UNDEFINED - Mark memory as accessible, with content undefined
|
||||
* PL_MAKE_MEM_DEFINED - Mark memory as accessible, with content defined
|
||||
*
|
||||
* With Valgrind in use, these directly map to the three respective Valgrind
|
||||
* macros. With ASan in use, the NOACCESS macro maps to poisoning the memory,
|
||||
* while the UNDEFINED/DEFINED macros unpoison memory.
|
||||
*
|
||||
* With no memory checker available, all macros expand to the empty statement.
|
||||
*/
|
||||
|
||||
/* WARNING: PL_SANITIZE_ADDRESS is for internal use by this header. Do NOT
|
||||
* define or test this macro in your code.
|
||||
*/
|
||||
#if defined(__has_feature)
|
||||
#if __has_feature(address_sanitizer)
|
||||
#define PL_SANITIZE_ADDRESS 1
|
||||
#endif
|
||||
#elif defined(__SANITIZE_ADDRESS__)
|
||||
#define PL_SANITIZE_ADDRESS 1
|
||||
#endif
|
||||
|
||||
#if defined(PL_SANITIZE_ADDRESS)
|
||||
|
||||
/* These definitions are usually provided through the
|
||||
* sanitizer/asan_interface.h header installed by ASan.
|
||||
* See https://github.com/google/sanitizers/wiki/AddressSanitizerManualPoisoning
|
||||
*/
|
||||
|
||||
PR_IMPORT(void) __asan_poison_memory_region(void const volatile *addr, size_t size);
|
||||
PR_IMPORT(void) __asan_unpoison_memory_region(void const volatile *addr, size_t size);
|
||||
|
||||
#define PL_MAKE_MEM_NOACCESS(addr, size) \
|
||||
__asan_poison_memory_region((addr), (size))
|
||||
|
||||
#define PL_MAKE_MEM_UNDEFINED(addr, size) \
|
||||
__asan_unpoison_memory_region((addr), (size))
|
||||
|
||||
#define PL_MAKE_MEM_DEFINED(addr, size) \
|
||||
__asan_unpoison_memory_region((addr), (size))
|
||||
|
||||
#else
|
||||
|
||||
#define PL_MAKE_MEM_NOACCESS(addr, size)
|
||||
#define PL_MAKE_MEM_UNDEFINED(addr, size)
|
||||
#define PL_MAKE_MEM_DEFINED(addr, size)
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* If the including .c file uses only one power-of-2 alignment, it may define
|
||||
* PL_ARENA_CONST_ALIGN_MASK to the alignment mask and save a few instructions
|
||||
* per ALLOCATE and GROW.
|
||||
*/
|
||||
#ifdef PL_ARENA_CONST_ALIGN_MASK
|
||||
#define PL_ARENA_ALIGN(pool, n) (((PRUword)(n) + PL_ARENA_CONST_ALIGN_MASK) \
|
||||
& ~PL_ARENA_CONST_ALIGN_MASK)
|
||||
|
||||
#define PL_INIT_ARENA_POOL(pool, name, size) \
|
||||
PL_InitArenaPool(pool, name, size, PL_ARENA_CONST_ALIGN_MASK + 1)
|
||||
#else
|
||||
#define PL_ARENA_ALIGN(pool, n) (((PRUword)(n) + (pool)->mask) & ~(pool)->mask)
|
||||
#endif
|
||||
|
||||
#define PL_ARENA_ALLOCATE(p, pool, nb) \
|
||||
PR_BEGIN_MACRO \
|
||||
PLArena *_a = (pool)->current; \
|
||||
PRUint32 _nb = PL_ARENA_ALIGN(pool, (PRUint32)nb); \
|
||||
PRUword _p = _a->avail; \
|
||||
if (_nb < (PRUint32)nb) { \
|
||||
_p = 0; \
|
||||
} else if (_nb > (_a->limit - _a->avail)) { \
|
||||
_p = (PRUword)PL_ArenaAllocate(pool, _nb); \
|
||||
} else { \
|
||||
_a->avail += _nb; \
|
||||
} \
|
||||
p = (void *)_p; \
|
||||
if (p) { \
|
||||
PL_MAKE_MEM_UNDEFINED(p, (PRUint32)nb); \
|
||||
PL_ArenaCountAllocation(pool, (PRUint32)nb); \
|
||||
} \
|
||||
PR_END_MACRO
|
||||
|
||||
#define PL_ARENA_GROW(p, pool, size, incr) \
|
||||
PR_BEGIN_MACRO \
|
||||
PLArena *_a = (pool)->current; \
|
||||
PRUint32 _incr = PL_ARENA_ALIGN(pool, (PRUint32)incr); \
|
||||
if (_incr < (PRUint32)incr) { \
|
||||
p = NULL; \
|
||||
} else if (_a->avail == (PRUword)(p) + PL_ARENA_ALIGN(pool, size) && \
|
||||
_incr <= (_a->limit - _a->avail)) { \
|
||||
PL_MAKE_MEM_UNDEFINED((unsigned char *)(p) + size, (PRUint32)incr); \
|
||||
_a->avail += _incr; \
|
||||
PL_ArenaCountInplaceGrowth(pool, size, (PRUint32)incr); \
|
||||
} else { \
|
||||
p = PL_ArenaGrow(pool, p, size, (PRUint32)incr); \
|
||||
} \
|
||||
if (p) {\
|
||||
PL_ArenaCountGrowth(pool, size, (PRUint32)incr); \
|
||||
} \
|
||||
PR_END_MACRO
|
||||
|
||||
#define PL_ARENA_MARK(pool) ((void *) (pool)->current->avail)
|
||||
#define PR_UPTRDIFF(p,q) ((PRUword)(p) - (PRUword)(q))
|
||||
|
||||
#define PL_CLEAR_UNUSED_PATTERN(a, pattern) \
|
||||
PR_BEGIN_MACRO \
|
||||
PR_ASSERT((a)->avail <= (a)->limit); \
|
||||
PL_MAKE_MEM_UNDEFINED((void*)(a)->avail, (a)->limit - (a)->avail); \
|
||||
memset((void*)(a)->avail, (pattern), (a)->limit - (a)->avail); \
|
||||
PR_END_MACRO
|
||||
#ifdef DEBUG
|
||||
#define PL_FREE_PATTERN 0xDA
|
||||
#define PL_CLEAR_UNUSED(a) PL_CLEAR_UNUSED_PATTERN((a), PL_FREE_PATTERN)
|
||||
#define PL_CLEAR_ARENA(a) \
|
||||
PR_BEGIN_MACRO \
|
||||
PL_MAKE_MEM_UNDEFINED((void*)(a), (a)->limit - (PRUword)(a)); \
|
||||
memset((void*)(a), PL_FREE_PATTERN, (a)->limit - (PRUword)(a)); \
|
||||
PR_END_MACRO
|
||||
#else
|
||||
#define PL_CLEAR_UNUSED(a)
|
||||
#define PL_CLEAR_ARENA(a)
|
||||
#endif
|
||||
|
||||
#define PL_ARENA_RELEASE(pool, mark) \
|
||||
PR_BEGIN_MACRO \
|
||||
char *_m = (char *)(mark); \
|
||||
PLArena *_a = (pool)->current; \
|
||||
if (PR_UPTRDIFF(_m, _a->base) <= PR_UPTRDIFF(_a->avail, _a->base)) { \
|
||||
_a->avail = (PRUword)PL_ARENA_ALIGN(pool, _m); \
|
||||
PL_CLEAR_UNUSED(_a); \
|
||||
PL_MAKE_MEM_NOACCESS((void*)_a->avail, _a->limit - _a->avail); \
|
||||
PL_ArenaCountRetract(pool, _m); \
|
||||
} else { \
|
||||
PL_ArenaRelease(pool, _m); \
|
||||
} \
|
||||
PL_ArenaCountRelease(pool, _m); \
|
||||
PR_END_MACRO
|
||||
|
||||
#ifdef PL_ARENAMETER
|
||||
#define PL_COUNT_ARENA(pool,op) ((pool)->stats.narenas op)
|
||||
#else
|
||||
#define PL_COUNT_ARENA(pool,op)
|
||||
#endif
|
||||
|
||||
#define PL_ARENA_DESTROY(pool, a, pnext) \
|
||||
PR_BEGIN_MACRO \
|
||||
PL_COUNT_ARENA(pool,--); \
|
||||
if ((pool)->current == (a)) (pool)->current = &(pool)->first; \
|
||||
*(pnext) = (a)->next; \
|
||||
PL_CLEAR_ARENA(a); \
|
||||
free(a); \
|
||||
(a) = 0; \
|
||||
PR_END_MACRO
|
||||
|
||||
/*
|
||||
** Initialize an arena pool with the given name for debugging and metering,
|
||||
** with a minimum gross size per arena of size bytes. The net size per arena
|
||||
** is smaller than the gross size by a header of four pointers plus any
|
||||
** necessary padding for alignment.
|
||||
**
|
||||
** Note: choose a gross size that's a power of two to avoid the heap allocator
|
||||
** rounding the size up.
|
||||
**/
|
||||
PR_EXTERN(void) PL_InitArenaPool(
|
||||
PLArenaPool *pool, const char *name, PRUint32 size, PRUint32 align);
|
||||
|
||||
/*
|
||||
** Finish using arenas, freeing all memory associated with them.
|
||||
** NOTE: this function is now a no-op. If you want to free a single
|
||||
** PLArenaPoolUse use PL_FreeArenaPool() or PL_FinishArenaPool().
|
||||
**/
|
||||
PR_EXTERN(void) PL_ArenaFinish(void);
|
||||
|
||||
/*
|
||||
** Free the arenas in pool. The user may continue to allocate from pool
|
||||
** after calling this function. There is no need to call PL_InitArenaPool()
|
||||
** again unless PL_FinishArenaPool(pool) has been called.
|
||||
**/
|
||||
PR_EXTERN(void) PL_FreeArenaPool(PLArenaPool *pool);
|
||||
|
||||
/*
|
||||
** Free the arenas in pool and finish using it altogether.
|
||||
**/
|
||||
PR_EXTERN(void) PL_FinishArenaPool(PLArenaPool *pool);
|
||||
|
||||
/*
|
||||
** Compact all of the arenas in a pool so that no space is wasted.
|
||||
** NOT IMPLEMENTED. Do not use.
|
||||
**/
|
||||
PR_EXTERN(void) PL_CompactArenaPool(PLArenaPool *pool);
|
||||
|
||||
/*
|
||||
** Friend functions used by the PL_ARENA_*() macros.
|
||||
**
|
||||
** WARNING: do not call these functions directly. Always use the
|
||||
** PL_ARENA_*() macros.
|
||||
**/
|
||||
PR_EXTERN(void *) PL_ArenaAllocate(PLArenaPool *pool, PRUint32 nb);
|
||||
|
||||
PR_EXTERN(void *) PL_ArenaGrow(
|
||||
PLArenaPool *pool, void *p, PRUint32 size, PRUint32 incr);
|
||||
|
||||
PR_EXTERN(void) PL_ArenaRelease(PLArenaPool *pool, char *mark);
|
||||
|
||||
/*
|
||||
** memset contents of all arenas in pool to pattern
|
||||
*/
|
||||
PR_EXTERN(void) PL_ClearArenaPool(PLArenaPool *pool, PRInt32 pattern);
|
||||
|
||||
/*
|
||||
** A function like malloc_size() or malloc_usable_size() that measures the
|
||||
** size of a heap block.
|
||||
*/
|
||||
typedef size_t (*PLMallocSizeFn)(const void *ptr);
|
||||
|
||||
/*
|
||||
** Measure all memory used by a PLArenaPool, excluding the PLArenaPool
|
||||
** structure.
|
||||
*/
|
||||
PR_EXTERN(size_t) PL_SizeOfArenaPoolExcludingPool(
|
||||
const PLArenaPool *pool, PLMallocSizeFn mallocSizeOf);
|
||||
|
||||
#ifdef PL_ARENAMETER
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
PR_EXTERN(void) PL_ArenaCountAllocation(PLArenaPool *pool, PRUint32 nb);
|
||||
|
||||
PR_EXTERN(void) PL_ArenaCountInplaceGrowth(
|
||||
PLArenaPool *pool, PRUint32 size, PRUint32 incr);
|
||||
|
||||
PR_EXTERN(void) PL_ArenaCountGrowth(
|
||||
PLArenaPool *pool, PRUint32 size, PRUint32 incr);
|
||||
|
||||
PR_EXTERN(void) PL_ArenaCountRelease(PLArenaPool *pool, char *mark);
|
||||
|
||||
PR_EXTERN(void) PL_ArenaCountRetract(PLArenaPool *pool, char *mark);
|
||||
|
||||
PR_EXTERN(void) PL_DumpArenaStats(FILE *fp);
|
||||
|
||||
#else /* !PL_ARENAMETER */
|
||||
|
||||
#define PL_ArenaCountAllocation(ap, nb) /* nothing */
|
||||
#define PL_ArenaCountInplaceGrowth(ap, size, incr) /* nothing */
|
||||
#define PL_ArenaCountGrowth(ap, size, incr) /* nothing */
|
||||
#define PL_ArenaCountRelease(ap, mark) /* nothing */
|
||||
#define PL_ArenaCountRetract(ap, mark) /* nothing */
|
||||
|
||||
#endif /* !PL_ARENAMETER */
|
||||
|
||||
PR_END_EXTERN_C
|
||||
|
||||
#endif /* plarena_h___ */
|
||||
12
nsprpub/lib/ds/plarenas.h
Normal file
12
nsprpub/lib/ds/plarenas.h
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
/*
|
||||
** PLArena-related declarations used to be split between plarenas.h and
|
||||
** plarena.h. That split wasn't useful, so now all the declarations are in
|
||||
** plarena.h. However, this file still exists so that any old code that
|
||||
** includes it will still work.
|
||||
**/
|
||||
#include "plarena.h"
|
||||
60
nsprpub/lib/ds/plds.def
Normal file
60
nsprpub/lib/ds/plds.def
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
;+#
|
||||
;+# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
;+# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
;+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
;+#
|
||||
;+# OK, this file is meant to support SUN, LINUX, AIX, OS/2 and WINDOWS
|
||||
;+# 1. For all unix platforms, the string ";-" means "remove this line"
|
||||
;+# 2. For all unix platforms, the string " DATA " will be removed from any
|
||||
;+# line on which it occurs.
|
||||
;+# 3. Lines containing ";+" will have ";+" removed on SUN and LINUX.
|
||||
;+# On AIX, lines containing ";+" will be removed.
|
||||
;+# 4. For all unix platforms, the string ";;" will thave the ";;" removed.
|
||||
;+# 5. For all unix platforms, after the above processing has taken place,
|
||||
;+# all characters after the first ";" on the line will be removed.
|
||||
;+# And for AIX, the first ";" will also be removed.
|
||||
;+# This file is passed directly to windows. Since ';' is a comment, all UNIX
|
||||
;+# directives are hidden behind ";", ";+", and ";-"
|
||||
;+NSPR_4.0 {
|
||||
;+ global:
|
||||
LIBRARY plds4 ;-
|
||||
EXPORTS ;-
|
||||
PL_ArenaAllocate;
|
||||
PL_ArenaFinish;
|
||||
PL_ArenaGrow;
|
||||
PL_ArenaRelease;
|
||||
PL_CompactArenaPool;
|
||||
PL_CompareStrings;
|
||||
PL_CompareValues;
|
||||
PL_FinishArenaPool;
|
||||
PL_FreeArenaPool;
|
||||
PL_HashString;
|
||||
PL_HashTableAdd;
|
||||
PL_HashTableDestroy;
|
||||
PL_HashTableDump;
|
||||
PL_HashTableEnumerateEntries;
|
||||
PL_HashTableLookup;
|
||||
PL_HashTableRawAdd;
|
||||
PL_HashTableRawLookup;
|
||||
PL_HashTableRawRemove;
|
||||
PL_HashTableRemove;
|
||||
PL_InitArenaPool;
|
||||
PL_NewHashTable;
|
||||
libVersionPoint;
|
||||
;+ local: *;
|
||||
;+};
|
||||
;+
|
||||
;+NSPR_4.1 {
|
||||
;+ global:
|
||||
PL_HashTableLookupConst;
|
||||
PL_HashTableRawLookupConst;
|
||||
;+} NSPR_4.0;
|
||||
;+
|
||||
;+NSPR_4.8.5 {
|
||||
;+ global:
|
||||
PL_ClearArenaPool;
|
||||
;+} NSPR_4.1;
|
||||
;+NSPR_4.9.6 {
|
||||
;+ global:
|
||||
PL_SizeOfArenaPoolExcludingPool;
|
||||
;+} NSPR_4.8.5;
|
||||
69
nsprpub/lib/ds/plds.rc
Normal file
69
nsprpub/lib/ds/plds.rc
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "prinit.h"
|
||||
#include <winver.h>
|
||||
|
||||
#define MY_LIBNAME "plds"
|
||||
#define MY_FILEDESCRIPTION "PLDS Library"
|
||||
|
||||
#define STRINGIZE(x) #x
|
||||
#define STRINGIZE2(x) STRINGIZE(x)
|
||||
#define PR_VMAJOR_STR STRINGIZE2(PR_VMAJOR)
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define MY_DEBUG_STR " (debug)"
|
||||
#define MY_FILEFLAGS_1 VS_FF_DEBUG
|
||||
#else
|
||||
#define MY_DEBUG_STR ""
|
||||
#define MY_FILEFLAGS_1 0x0L
|
||||
#endif
|
||||
#if PR_BETA
|
||||
#define MY_FILEFLAGS_2 MY_FILEFLAGS_1|VS_FF_PRERELEASE
|
||||
#else
|
||||
#define MY_FILEFLAGS_2 MY_FILEFLAGS_1
|
||||
#endif
|
||||
|
||||
#ifdef WINNT
|
||||
#define MY_FILEOS VOS_NT_WINDOWS32
|
||||
#define MY_INTERNAL_NAME "lib" MY_LIBNAME PR_VMAJOR_STR
|
||||
#else
|
||||
#define MY_FILEOS VOS__WINDOWS32
|
||||
#define MY_INTERNAL_NAME MY_LIBNAME PR_VMAJOR_STR
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Version-information resource
|
||||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION PR_VMAJOR,PR_VMINOR,PR_VPATCH,0
|
||||
PRODUCTVERSION PR_VMAJOR,PR_VMINOR,PR_VPATCH,0
|
||||
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
|
||||
FILEFLAGS MY_FILEFLAGS_2
|
||||
FILEOS MY_FILEOS
|
||||
FILETYPE VFT_DLL
|
||||
FILESUBTYPE 0x0L // not used
|
||||
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040904B0" // Lang=US English, CharSet=Unicode
|
||||
BEGIN
|
||||
VALUE "CompanyName", "Mozilla Foundation\0"
|
||||
VALUE "FileDescription", MY_FILEDESCRIPTION MY_DEBUG_STR "\0"
|
||||
VALUE "FileVersion", PR_VERSION "\0"
|
||||
VALUE "InternalName", MY_INTERNAL_NAME "\0"
|
||||
VALUE "OriginalFilename", MY_INTERNAL_NAME ".dll\0"
|
||||
VALUE "ProductName", "Netscape Portable Runtime\0"
|
||||
VALUE "ProductVersion", PR_VERSION "\0"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x409, 1200
|
||||
END
|
||||
END
|
||||
483
nsprpub/lib/ds/plhash.c
Normal file
483
nsprpub/lib/ds/plhash.c
Normal file
|
|
@ -0,0 +1,483 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
/*
|
||||
* PL hash table package.
|
||||
*/
|
||||
#include "plhash.h"
|
||||
#include "prbit.h"
|
||||
#include "prlog.h"
|
||||
#include "prmem.h"
|
||||
#include "prtypes.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
/* Compute the number of buckets in ht */
|
||||
#define NBUCKETS(ht) (1 << (PL_HASH_BITS - (ht)->shift))
|
||||
|
||||
/* The smallest table has 16 buckets */
|
||||
#define MINBUCKETSLOG2 4
|
||||
#define MINBUCKETS (1 << MINBUCKETSLOG2)
|
||||
|
||||
/* Compute the maximum entries given n buckets that we will tolerate, ~90% */
|
||||
#define OVERLOADED(n) ((n) - ((n) >> 3))
|
||||
|
||||
/* Compute the number of entries below which we shrink the table by half */
|
||||
#define UNDERLOADED(n) (((n) > MINBUCKETS) ? ((n) >> 2) : 0)
|
||||
|
||||
/*
|
||||
** Stubs for default hash allocator ops.
|
||||
*/
|
||||
static void * PR_CALLBACK
|
||||
DefaultAllocTable(void *pool, PRSize size)
|
||||
{
|
||||
return PR_MALLOC(size);
|
||||
}
|
||||
|
||||
static void PR_CALLBACK
|
||||
DefaultFreeTable(void *pool, void *item)
|
||||
{
|
||||
PR_Free(item);
|
||||
}
|
||||
|
||||
static PLHashEntry * PR_CALLBACK
|
||||
DefaultAllocEntry(void *pool, const void *key)
|
||||
{
|
||||
return PR_NEW(PLHashEntry);
|
||||
}
|
||||
|
||||
static void PR_CALLBACK
|
||||
DefaultFreeEntry(void *pool, PLHashEntry *he, PRUintn flag)
|
||||
{
|
||||
if (flag == HT_FREE_ENTRY)
|
||||
PR_Free(he);
|
||||
}
|
||||
|
||||
static PLHashAllocOps defaultHashAllocOps = {
|
||||
DefaultAllocTable, DefaultFreeTable,
|
||||
DefaultAllocEntry, DefaultFreeEntry
|
||||
};
|
||||
|
||||
PR_IMPLEMENT(PLHashTable *)
|
||||
PL_NewHashTable(PRUint32 n, PLHashFunction keyHash,
|
||||
PLHashComparator keyCompare, PLHashComparator valueCompare,
|
||||
const PLHashAllocOps *allocOps, void *allocPriv)
|
||||
{
|
||||
PLHashTable *ht;
|
||||
PRSize nb;
|
||||
|
||||
if (n <= MINBUCKETS) {
|
||||
n = MINBUCKETSLOG2;
|
||||
} else {
|
||||
n = PR_CeilingLog2(n);
|
||||
if ((PRInt32)n < 0)
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!allocOps) allocOps = &defaultHashAllocOps;
|
||||
|
||||
ht = (PLHashTable*)((*allocOps->allocTable)(allocPriv, sizeof *ht));
|
||||
if (!ht)
|
||||
return 0;
|
||||
memset(ht, 0, sizeof *ht);
|
||||
ht->shift = PL_HASH_BITS - n;
|
||||
n = 1 << n;
|
||||
nb = n * sizeof(PLHashEntry *);
|
||||
ht->buckets = (PLHashEntry**)((*allocOps->allocTable)(allocPriv, nb));
|
||||
if (!ht->buckets) {
|
||||
(*allocOps->freeTable)(allocPriv, ht);
|
||||
return 0;
|
||||
}
|
||||
memset(ht->buckets, 0, nb);
|
||||
|
||||
ht->keyHash = keyHash;
|
||||
ht->keyCompare = keyCompare;
|
||||
ht->valueCompare = valueCompare;
|
||||
ht->allocOps = allocOps;
|
||||
ht->allocPriv = allocPriv;
|
||||
return ht;
|
||||
}
|
||||
|
||||
PR_IMPLEMENT(void)
|
||||
PL_HashTableDestroy(PLHashTable *ht)
|
||||
{
|
||||
PRUint32 i, n;
|
||||
PLHashEntry *he, *next;
|
||||
const PLHashAllocOps *allocOps = ht->allocOps;
|
||||
void *allocPriv = ht->allocPriv;
|
||||
|
||||
n = NBUCKETS(ht);
|
||||
for (i = 0; i < n; i++) {
|
||||
for (he = ht->buckets[i]; he; he = next) {
|
||||
next = he->next;
|
||||
(*allocOps->freeEntry)(allocPriv, he, HT_FREE_ENTRY);
|
||||
}
|
||||
}
|
||||
#ifdef DEBUG
|
||||
memset(ht->buckets, 0xDB, n * sizeof ht->buckets[0]);
|
||||
#endif
|
||||
(*allocOps->freeTable)(allocPriv, ht->buckets);
|
||||
#ifdef DEBUG
|
||||
memset(ht, 0xDB, sizeof *ht);
|
||||
#endif
|
||||
(*allocOps->freeTable)(allocPriv, ht);
|
||||
}
|
||||
|
||||
/*
|
||||
** Multiplicative hash, from Knuth 6.4.
|
||||
*/
|
||||
#define GOLDEN_RATIO 0x9E3779B9U /* 2/(1+sqrt(5))*(2^32) */
|
||||
|
||||
PR_IMPLEMENT(PLHashEntry **)
|
||||
PL_HashTableRawLookup(PLHashTable *ht, PLHashNumber keyHash, const void *key)
|
||||
{
|
||||
PLHashEntry *he, **hep, **hep0;
|
||||
PLHashNumber h;
|
||||
|
||||
#ifdef HASHMETER
|
||||
ht->nlookups++;
|
||||
#endif
|
||||
h = keyHash * GOLDEN_RATIO;
|
||||
h >>= ht->shift;
|
||||
hep = hep0 = &ht->buckets[h];
|
||||
while ((he = *hep) != 0) {
|
||||
if (he->keyHash == keyHash && (*ht->keyCompare)(key, he->key)) {
|
||||
/* Move to front of chain if not already there */
|
||||
if (hep != hep0) {
|
||||
*hep = he->next;
|
||||
he->next = *hep0;
|
||||
*hep0 = he;
|
||||
}
|
||||
return hep0;
|
||||
}
|
||||
hep = &he->next;
|
||||
#ifdef HASHMETER
|
||||
ht->nsteps++;
|
||||
#endif
|
||||
}
|
||||
return hep;
|
||||
}
|
||||
|
||||
/*
|
||||
** Same as PL_HashTableRawLookup but doesn't reorder the hash entries.
|
||||
*/
|
||||
PR_IMPLEMENT(PLHashEntry **)
|
||||
PL_HashTableRawLookupConst(PLHashTable *ht, PLHashNumber keyHash,
|
||||
const void *key)
|
||||
{
|
||||
PLHashEntry *he, **hep;
|
||||
PLHashNumber h;
|
||||
|
||||
#ifdef HASHMETER
|
||||
ht->nlookups++;
|
||||
#endif
|
||||
h = keyHash * GOLDEN_RATIO;
|
||||
h >>= ht->shift;
|
||||
hep = &ht->buckets[h];
|
||||
while ((he = *hep) != 0) {
|
||||
if (he->keyHash == keyHash && (*ht->keyCompare)(key, he->key)) {
|
||||
break;
|
||||
}
|
||||
hep = &he->next;
|
||||
#ifdef HASHMETER
|
||||
ht->nsteps++;
|
||||
#endif
|
||||
}
|
||||
return hep;
|
||||
}
|
||||
|
||||
PR_IMPLEMENT(PLHashEntry *)
|
||||
PL_HashTableRawAdd(PLHashTable *ht, PLHashEntry **hep,
|
||||
PLHashNumber keyHash, const void *key, void *value)
|
||||
{
|
||||
PRUint32 i, n;
|
||||
PLHashEntry *he, *next, **oldbuckets;
|
||||
PRSize nb;
|
||||
|
||||
/* Grow the table if it is overloaded */
|
||||
n = NBUCKETS(ht);
|
||||
if (ht->nentries >= OVERLOADED(n)) {
|
||||
oldbuckets = ht->buckets;
|
||||
nb = 2 * n * sizeof(PLHashEntry *);
|
||||
ht->buckets = (PLHashEntry**)
|
||||
((*ht->allocOps->allocTable)(ht->allocPriv, nb));
|
||||
if (!ht->buckets) {
|
||||
ht->buckets = oldbuckets;
|
||||
return 0;
|
||||
}
|
||||
memset(ht->buckets, 0, nb);
|
||||
#ifdef HASHMETER
|
||||
ht->ngrows++;
|
||||
#endif
|
||||
ht->shift--;
|
||||
|
||||
for (i = 0; i < n; i++) {
|
||||
for (he = oldbuckets[i]; he; he = next) {
|
||||
next = he->next;
|
||||
hep = PL_HashTableRawLookup(ht, he->keyHash, he->key);
|
||||
PR_ASSERT(*hep == 0);
|
||||
he->next = 0;
|
||||
*hep = he;
|
||||
}
|
||||
}
|
||||
#ifdef DEBUG
|
||||
memset(oldbuckets, 0xDB, n * sizeof oldbuckets[0]);
|
||||
#endif
|
||||
(*ht->allocOps->freeTable)(ht->allocPriv, oldbuckets);
|
||||
hep = PL_HashTableRawLookup(ht, keyHash, key);
|
||||
}
|
||||
|
||||
/* Make a new key value entry */
|
||||
he = (*ht->allocOps->allocEntry)(ht->allocPriv, key);
|
||||
if (!he)
|
||||
return 0;
|
||||
he->keyHash = keyHash;
|
||||
he->key = key;
|
||||
he->value = value;
|
||||
he->next = *hep;
|
||||
*hep = he;
|
||||
ht->nentries++;
|
||||
return he;
|
||||
}
|
||||
|
||||
PR_IMPLEMENT(PLHashEntry *)
|
||||
PL_HashTableAdd(PLHashTable *ht, const void *key, void *value)
|
||||
{
|
||||
PLHashNumber keyHash;
|
||||
PLHashEntry *he, **hep;
|
||||
|
||||
keyHash = (*ht->keyHash)(key);
|
||||
hep = PL_HashTableRawLookup(ht, keyHash, key);
|
||||
if ((he = *hep) != 0) {
|
||||
/* Hit; see if values match */
|
||||
if ((*ht->valueCompare)(he->value, value)) {
|
||||
/* key,value pair is already present in table */
|
||||
return he;
|
||||
}
|
||||
if (he->value)
|
||||
(*ht->allocOps->freeEntry)(ht->allocPriv, he, HT_FREE_VALUE);
|
||||
he->value = value;
|
||||
return he;
|
||||
}
|
||||
return PL_HashTableRawAdd(ht, hep, keyHash, key, value);
|
||||
}
|
||||
|
||||
PR_IMPLEMENT(void)
|
||||
PL_HashTableRawRemove(PLHashTable *ht, PLHashEntry **hep, PLHashEntry *he)
|
||||
{
|
||||
PRUint32 i, n;
|
||||
PLHashEntry *next, **oldbuckets;
|
||||
PRSize nb;
|
||||
|
||||
*hep = he->next;
|
||||
(*ht->allocOps->freeEntry)(ht->allocPriv, he, HT_FREE_ENTRY);
|
||||
|
||||
/* Shrink table if it's underloaded */
|
||||
n = NBUCKETS(ht);
|
||||
if (--ht->nentries < UNDERLOADED(n)) {
|
||||
oldbuckets = ht->buckets;
|
||||
nb = n * sizeof(PLHashEntry*) / 2;
|
||||
ht->buckets = (PLHashEntry**)(
|
||||
(*ht->allocOps->allocTable)(ht->allocPriv, nb));
|
||||
if (!ht->buckets) {
|
||||
ht->buckets = oldbuckets;
|
||||
return;
|
||||
}
|
||||
memset(ht->buckets, 0, nb);
|
||||
#ifdef HASHMETER
|
||||
ht->nshrinks++;
|
||||
#endif
|
||||
ht->shift++;
|
||||
|
||||
for (i = 0; i < n; i++) {
|
||||
for (he = oldbuckets[i]; he; he = next) {
|
||||
next = he->next;
|
||||
hep = PL_HashTableRawLookup(ht, he->keyHash, he->key);
|
||||
PR_ASSERT(*hep == 0);
|
||||
he->next = 0;
|
||||
*hep = he;
|
||||
}
|
||||
}
|
||||
#ifdef DEBUG
|
||||
memset(oldbuckets, 0xDB, n * sizeof oldbuckets[0]);
|
||||
#endif
|
||||
(*ht->allocOps->freeTable)(ht->allocPriv, oldbuckets);
|
||||
}
|
||||
}
|
||||
|
||||
PR_IMPLEMENT(PRBool)
|
||||
PL_HashTableRemove(PLHashTable *ht, const void *key)
|
||||
{
|
||||
PLHashNumber keyHash;
|
||||
PLHashEntry *he, **hep;
|
||||
|
||||
keyHash = (*ht->keyHash)(key);
|
||||
hep = PL_HashTableRawLookup(ht, keyHash, key);
|
||||
if ((he = *hep) == 0)
|
||||
return PR_FALSE;
|
||||
|
||||
/* Hit; remove element */
|
||||
PL_HashTableRawRemove(ht, hep, he);
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
PR_IMPLEMENT(void *)
|
||||
PL_HashTableLookup(PLHashTable *ht, const void *key)
|
||||
{
|
||||
PLHashNumber keyHash;
|
||||
PLHashEntry *he, **hep;
|
||||
|
||||
keyHash = (*ht->keyHash)(key);
|
||||
hep = PL_HashTableRawLookup(ht, keyHash, key);
|
||||
if ((he = *hep) != 0) {
|
||||
return he->value;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
** Same as PL_HashTableLookup but doesn't reorder the hash entries.
|
||||
*/
|
||||
PR_IMPLEMENT(void *)
|
||||
PL_HashTableLookupConst(PLHashTable *ht, const void *key)
|
||||
{
|
||||
PLHashNumber keyHash;
|
||||
PLHashEntry *he, **hep;
|
||||
|
||||
keyHash = (*ht->keyHash)(key);
|
||||
hep = PL_HashTableRawLookupConst(ht, keyHash, key);
|
||||
if ((he = *hep) != 0) {
|
||||
return he->value;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
** Iterate over the entries in the hash table calling func for each
|
||||
** entry found. Stop if "f" says to (return value & PR_ENUMERATE_STOP).
|
||||
** Return a count of the number of elements scanned.
|
||||
*/
|
||||
PR_IMPLEMENT(int)
|
||||
PL_HashTableEnumerateEntries(PLHashTable *ht, PLHashEnumerator f, void *arg)
|
||||
{
|
||||
PLHashEntry *he, **hep;
|
||||
PRUint32 i, nbuckets;
|
||||
int rv, n = 0;
|
||||
PLHashEntry *todo = 0;
|
||||
|
||||
nbuckets = NBUCKETS(ht);
|
||||
for (i = 0; i < nbuckets; i++) {
|
||||
hep = &ht->buckets[i];
|
||||
while ((he = *hep) != 0) {
|
||||
rv = (*f)(he, n, arg);
|
||||
n++;
|
||||
if (rv & (HT_ENUMERATE_REMOVE | HT_ENUMERATE_UNHASH)) {
|
||||
*hep = he->next;
|
||||
if (rv & HT_ENUMERATE_REMOVE) {
|
||||
he->next = todo;
|
||||
todo = he;
|
||||
}
|
||||
} else {
|
||||
hep = &he->next;
|
||||
}
|
||||
if (rv & HT_ENUMERATE_STOP) {
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
out:
|
||||
hep = &todo;
|
||||
while ((he = *hep) != 0) {
|
||||
PL_HashTableRawRemove(ht, hep, he);
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
#ifdef HASHMETER
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
|
||||
PR_IMPLEMENT(void)
|
||||
PL_HashTableDumpMeter(PLHashTable *ht, PLHashEnumerator dump, FILE *fp)
|
||||
{
|
||||
double mean, variance;
|
||||
PRUint32 nchains, nbuckets;
|
||||
PRUint32 i, n, maxChain, maxChainLen;
|
||||
PLHashEntry *he;
|
||||
|
||||
variance = 0;
|
||||
nchains = 0;
|
||||
maxChainLen = 0;
|
||||
nbuckets = NBUCKETS(ht);
|
||||
for (i = 0; i < nbuckets; i++) {
|
||||
he = ht->buckets[i];
|
||||
if (!he)
|
||||
continue;
|
||||
nchains++;
|
||||
for (n = 0; he; he = he->next)
|
||||
n++;
|
||||
variance += n * n;
|
||||
if (n > maxChainLen) {
|
||||
maxChainLen = n;
|
||||
maxChain = i;
|
||||
}
|
||||
}
|
||||
mean = (double)ht->nentries / nchains;
|
||||
variance = fabs(variance / nchains - mean * mean);
|
||||
|
||||
fprintf(fp, "\nHash table statistics:\n");
|
||||
fprintf(fp, " number of lookups: %u\n", ht->nlookups);
|
||||
fprintf(fp, " number of entries: %u\n", ht->nentries);
|
||||
fprintf(fp, " number of grows: %u\n", ht->ngrows);
|
||||
fprintf(fp, " number of shrinks: %u\n", ht->nshrinks);
|
||||
fprintf(fp, " mean steps per hash: %g\n", (double)ht->nsteps
|
||||
/ ht->nlookups);
|
||||
fprintf(fp, "mean hash chain length: %g\n", mean);
|
||||
fprintf(fp, " standard deviation: %g\n", sqrt(variance));
|
||||
fprintf(fp, " max hash chain length: %u\n", maxChainLen);
|
||||
fprintf(fp, " max hash chain: [%u]\n", maxChain);
|
||||
|
||||
for (he = ht->buckets[maxChain], i = 0; he; he = he->next, i++)
|
||||
if ((*dump)(he, i, fp) != HT_ENUMERATE_NEXT)
|
||||
break;
|
||||
}
|
||||
#endif /* HASHMETER */
|
||||
|
||||
PR_IMPLEMENT(int)
|
||||
PL_HashTableDump(PLHashTable *ht, PLHashEnumerator dump, FILE *fp)
|
||||
{
|
||||
int count;
|
||||
|
||||
count = PL_HashTableEnumerateEntries(ht, dump, fp);
|
||||
#ifdef HASHMETER
|
||||
PL_HashTableDumpMeter(ht, dump, fp);
|
||||
#endif
|
||||
return count;
|
||||
}
|
||||
|
||||
PR_IMPLEMENT(PLHashNumber)
|
||||
PL_HashString(const void *key)
|
||||
{
|
||||
PLHashNumber h;
|
||||
const PRUint8 *s;
|
||||
|
||||
h = 0;
|
||||
for (s = (const PRUint8*)key; *s; s++)
|
||||
h = PR_ROTATE_LEFT32(h, 4) ^ *s;
|
||||
return h;
|
||||
}
|
||||
|
||||
PR_IMPLEMENT(int)
|
||||
PL_CompareStrings(const void *v1, const void *v2)
|
||||
{
|
||||
return strcmp((const char*)v1, (const char*)v2) == 0;
|
||||
}
|
||||
|
||||
PR_IMPLEMENT(int)
|
||||
PL_CompareValues(const void *v1, const void *v2)
|
||||
{
|
||||
return v1 == v2;
|
||||
}
|
||||
126
nsprpub/lib/ds/plhash.h
Normal file
126
nsprpub/lib/ds/plhash.h
Normal file
|
|
@ -0,0 +1,126 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef plhash_h___
|
||||
#define plhash_h___
|
||||
/*
|
||||
* API to portable hash table code.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include "prtypes.h"
|
||||
|
||||
PR_BEGIN_EXTERN_C
|
||||
|
||||
typedef struct PLHashEntry PLHashEntry;
|
||||
typedef struct PLHashTable PLHashTable;
|
||||
typedef PRUint32 PLHashNumber;
|
||||
#define PL_HASH_BITS 32 /* Number of bits in PLHashNumber */
|
||||
typedef PLHashNumber (PR_CALLBACK *PLHashFunction)(const void *key);
|
||||
typedef PRIntn (PR_CALLBACK *PLHashComparator)(const void *v1, const void *v2);
|
||||
|
||||
typedef PRIntn (PR_CALLBACK *PLHashEnumerator)(PLHashEntry *he, PRIntn i, void *arg);
|
||||
|
||||
/* Flag bits in PLHashEnumerator's return value */
|
||||
#define HT_ENUMERATE_NEXT 0 /* continue enumerating entries */
|
||||
#define HT_ENUMERATE_STOP 1 /* stop enumerating entries */
|
||||
#define HT_ENUMERATE_REMOVE 2 /* remove and free the current entry */
|
||||
#define HT_ENUMERATE_UNHASH 4 /* just unhash the current entry */
|
||||
|
||||
typedef struct PLHashAllocOps {
|
||||
void * (PR_CALLBACK *allocTable)(void *pool, PRSize size);
|
||||
void (PR_CALLBACK *freeTable)(void *pool, void *item);
|
||||
PLHashEntry * (PR_CALLBACK *allocEntry)(void *pool, const void *key);
|
||||
void (PR_CALLBACK *freeEntry)(void *pool, PLHashEntry *he, PRUintn flag);
|
||||
} PLHashAllocOps;
|
||||
|
||||
#define HT_FREE_VALUE 0 /* just free the entry's value */
|
||||
#define HT_FREE_ENTRY 1 /* free value and entire entry */
|
||||
|
||||
struct PLHashEntry {
|
||||
PLHashEntry *next; /* hash chain linkage */
|
||||
PLHashNumber keyHash; /* key hash function result */
|
||||
const void *key; /* ptr to opaque key */
|
||||
void *value; /* ptr to opaque value */
|
||||
};
|
||||
|
||||
struct PLHashTable {
|
||||
PLHashEntry **buckets; /* vector of hash buckets */
|
||||
PRUint32 nentries; /* number of entries in table */
|
||||
PRUint32 shift; /* multiplicative hash shift */
|
||||
PLHashFunction keyHash; /* key hash function */
|
||||
PLHashComparator keyCompare; /* key comparison function */
|
||||
PLHashComparator valueCompare; /* value comparison function */
|
||||
const PLHashAllocOps *allocOps; /* allocation operations */
|
||||
void *allocPriv; /* allocation private data */
|
||||
#ifdef HASHMETER
|
||||
PRUint32 nlookups; /* total number of lookups */
|
||||
PRUint32 nsteps; /* number of hash chains traversed */
|
||||
PRUint32 ngrows; /* number of table expansions */
|
||||
PRUint32 nshrinks; /* number of table contractions */
|
||||
#endif
|
||||
};
|
||||
|
||||
/*
|
||||
* Create a new hash table.
|
||||
* If allocOps is null, use default allocator ops built on top of malloc().
|
||||
*/
|
||||
PR_EXTERN(PLHashTable *)
|
||||
PL_NewHashTable(PRUint32 numBuckets, PLHashFunction keyHash,
|
||||
PLHashComparator keyCompare, PLHashComparator valueCompare,
|
||||
const PLHashAllocOps *allocOps, void *allocPriv);
|
||||
|
||||
PR_EXTERN(void)
|
||||
PL_HashTableDestroy(PLHashTable *ht);
|
||||
|
||||
/* Higher level access methods */
|
||||
PR_EXTERN(PLHashEntry *)
|
||||
PL_HashTableAdd(PLHashTable *ht, const void *key, void *value);
|
||||
|
||||
PR_EXTERN(PRBool)
|
||||
PL_HashTableRemove(PLHashTable *ht, const void *key);
|
||||
|
||||
PR_EXTERN(void *)
|
||||
PL_HashTableLookup(PLHashTable *ht, const void *key);
|
||||
|
||||
PR_EXTERN(void *)
|
||||
PL_HashTableLookupConst(PLHashTable *ht, const void *key);
|
||||
|
||||
PR_EXTERN(PRIntn)
|
||||
PL_HashTableEnumerateEntries(PLHashTable *ht, PLHashEnumerator f, void *arg);
|
||||
|
||||
/* General-purpose C string hash function. */
|
||||
PR_EXTERN(PLHashNumber)
|
||||
PL_HashString(const void *key);
|
||||
|
||||
/* Compare strings using strcmp(), return true if equal. */
|
||||
PR_EXTERN(PRIntn)
|
||||
PL_CompareStrings(const void *v1, const void *v2);
|
||||
|
||||
/* Stub function just returns v1 == v2 */
|
||||
PR_EXTERN(PRIntn)
|
||||
PL_CompareValues(const void *v1, const void *v2);
|
||||
|
||||
/* Low level access methods */
|
||||
PR_EXTERN(PLHashEntry **)
|
||||
PL_HashTableRawLookup(PLHashTable *ht, PLHashNumber keyHash, const void *key);
|
||||
|
||||
PR_EXTERN(PLHashEntry **)
|
||||
PL_HashTableRawLookupConst(PLHashTable *ht, PLHashNumber keyHash,
|
||||
const void *key);
|
||||
|
||||
PR_EXTERN(PLHashEntry *)
|
||||
PL_HashTableRawAdd(PLHashTable *ht, PLHashEntry **hep, PLHashNumber keyHash,
|
||||
const void *key, void *value);
|
||||
|
||||
PR_EXTERN(void)
|
||||
PL_HashTableRawRemove(PLHashTable *ht, PLHashEntry **hep, PLHashEntry *he);
|
||||
|
||||
/* This can be trivially implemented using PL_HashTableEnumerateEntries. */
|
||||
PR_EXTERN(PRIntn)
|
||||
PL_HashTableDump(PLHashTable *ht, PLHashEnumerator dump, FILE *fp);
|
||||
|
||||
PR_END_EXTERN_C
|
||||
|
||||
#endif /* plhash_h___ */
|
||||
93
nsprpub/lib/ds/plvrsion.c
Normal file
93
nsprpub/lib/ds/plvrsion.c
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "prinit.h"
|
||||
#include "prvrsion.h"
|
||||
|
||||
/************************************************************************/
|
||||
/**************************IDENTITY AND VERSIONING***********************/
|
||||
/************************************************************************/
|
||||
#include "_pl_bld.h"
|
||||
#if !defined(_BUILD_TIME)
|
||||
#ifdef HAVE_LONG_LONG
|
||||
#define _BUILD_TIME 0
|
||||
#else
|
||||
#define _BUILD_TIME {0, 0}
|
||||
#endif
|
||||
#endif
|
||||
#if !defined(_BUILD_STRING)
|
||||
#define _BUILD_STRING ""
|
||||
#endif
|
||||
#if !defined(_PRODUCTION)
|
||||
#define _PRODUCTION ""
|
||||
#endif
|
||||
#if defined(DEBUG)
|
||||
#define _DEBUG_STRING " (debug)"
|
||||
#else
|
||||
#define _DEBUG_STRING ""
|
||||
#endif
|
||||
|
||||
/*
|
||||
* A trick to expand the PR_VMAJOR macro before concatenation.
|
||||
*/
|
||||
#define CONCAT(x, y) x ## y
|
||||
#define CONCAT2(x, y) CONCAT(x, y)
|
||||
#define VERSION_DESC_NAME CONCAT2(prVersionDescription_libplds, PR_VMAJOR)
|
||||
|
||||
PRVersionDescription VERSION_DESC_NAME =
|
||||
{
|
||||
/* version */ 2, /* this is the only one supported */
|
||||
/* buildTime */ _BUILD_TIME, /* usecs since midnight 1/1/1970 GMT */
|
||||
/* buildTimeString */ _BUILD_STRING, /* ditto, but human readable */
|
||||
/* vMajor */ PR_VMAJOR, /* NSPR's version number */
|
||||
/* vMinor */ PR_VMINOR, /* and minor version */
|
||||
/* vPatch */ PR_VPATCH, /* and patch */
|
||||
/* beta */ PR_BETA, /* beta build boolean */
|
||||
#if defined(DEBUG)
|
||||
/* debug */ PR_TRUE, /* a debug build */
|
||||
#else
|
||||
/* debug */ PR_FALSE, /* an optomized build */
|
||||
#endif
|
||||
/* special */ PR_FALSE, /* they're all special, but ... */
|
||||
/* filename */ _PRODUCTION, /* the produced library name */
|
||||
/* description */ "Portable runtime", /* what we are */
|
||||
/* security */ "N/A", /* not applicable here */
|
||||
/* copywrite */ "Copyright (c) 1998 Netscape Communications Corporation. All Rights Reserved",
|
||||
/* comment */ "http://www.mozilla.org/MPL/",
|
||||
/* specialString */ ""
|
||||
};
|
||||
|
||||
#ifdef XP_UNIX
|
||||
|
||||
/*
|
||||
* Version information for the 'ident' and 'what commands
|
||||
*
|
||||
* NOTE: the first component of the concatenated rcsid string
|
||||
* must not end in a '$' to prevent rcs keyword substitution.
|
||||
*/
|
||||
static char rcsid[] = "$Header: NSPR " PR_VERSION _DEBUG_STRING
|
||||
" " _BUILD_STRING " $";
|
||||
static char sccsid[] = "@(#)NSPR " PR_VERSION _DEBUG_STRING
|
||||
" " _BUILD_STRING;
|
||||
|
||||
#endif /* XP_UNIX */
|
||||
|
||||
PR_IMPLEMENT(const PRVersionDescription*) libVersionPoint()
|
||||
{
|
||||
#ifdef XP_UNIX
|
||||
/*
|
||||
* Add dummy references to rcsid and sccsid to prevent them
|
||||
* from being optimized away as unused variables.
|
||||
*/
|
||||
const char *dummy;
|
||||
|
||||
dummy = rcsid;
|
||||
dummy = sccsid;
|
||||
#endif
|
||||
return &VERSION_DESC_NAME;
|
||||
} /* versionEntryPointType */
|
||||
|
||||
/* plvrsion.c */
|
||||
|
||||
1
nsprpub/lib/libc/.cvsignore
Normal file
1
nsprpub/lib/libc/.cvsignore
Normal file
|
|
@ -0,0 +1 @@
|
|||
Makefile
|
||||
24
nsprpub/lib/libc/Makefile.in
Normal file
24
nsprpub/lib/libc/Makefile.in
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
#
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
#! gmake
|
||||
|
||||
MOD_DEPTH = ../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(MOD_DEPTH)/config/autoconf.mk
|
||||
|
||||
export NSPR20=1
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
DIRS = include src
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
export:: $(TARGETS)
|
||||
|
||||
20
nsprpub/lib/libc/README
Normal file
20
nsprpub/lib/libc/README
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
NSPR 2.0 libc functions
|
||||
-----------------------
|
||||
|
||||
Last edited: AOF 04 March 1997
|
||||
|
||||
This directory contains various libc-types of functions. All functions in
|
||||
this directory are platform independent, thread friendly (both safe and
|
||||
efficient). They are contributed from various sources, though the contri-
|
||||
butions are monitored by the NSPR group (mailto:freier).
|
||||
|
||||
All API items exported by these functions will contain the same three
|
||||
character prefix, "PL_" (Portable Library). Internal function names
|
||||
that are not exported (static) are of little concern, though some caution
|
||||
must be used on those elements that are 'extern' but not really intended
|
||||
to be part of the API. Those should all have a prefix of "_PL_" (is that
|
||||
legal?).
|
||||
|
||||
The responsibility for contributions in this area are distributed among
|
||||
all interested parties.
|
||||
|
||||
1
nsprpub/lib/libc/include/.cvsignore
Normal file
1
nsprpub/lib/libc/include/.cvsignore
Normal file
|
|
@ -0,0 +1 @@
|
|||
Makefile
|
||||
24
nsprpub/lib/libc/include/Makefile.in
Normal file
24
nsprpub/lib/libc/include/Makefile.in
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
#
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
#! gmake
|
||||
|
||||
MOD_DEPTH = ../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(MOD_DEPTH)/config/autoconf.mk
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
HEADERS = $(wildcard $(srcdir)/*.h)
|
||||
|
||||
RELEASE_HEADERS = $(HEADERS)
|
||||
RELEASE_HEADERS_DEST = $(RELEASE_INCLUDE_DIR)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
export:: $(HEADERS)
|
||||
$(INSTALL) -m 444 $(HEADERS) $(dist_includedir)
|
||||
7
nsprpub/lib/libc/include/README
Normal file
7
nsprpub/lib/libc/include/README
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
NSPR 2.0 libc functions
|
||||
-----------------------
|
||||
|
||||
Last edited: AOF 04 March 1997
|
||||
|
||||
This directory contains the API for various libc-types of functions.
|
||||
|
||||
76
nsprpub/lib/libc/include/plbase64.h
Normal file
76
nsprpub/lib/libc/include/plbase64.h
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef _plbase64_h
|
||||
#define _plbase64_h
|
||||
|
||||
#include "prtypes.h"
|
||||
|
||||
PR_BEGIN_EXTERN_C
|
||||
|
||||
/*
|
||||
* PL_Base64Encode
|
||||
*
|
||||
* This routine encodes the data pointed to by the "src" parameter using the
|
||||
* base64 algorithm, and returns a pointer to the result. If the "srclen"
|
||||
* parameter is not zero, it specifies the length of the source data. If it
|
||||
* is zero, the source data is assumed to be null-terminated, and PL_strlen
|
||||
* is used to determine the source length. If the "dest" parameter is not
|
||||
* null, it is assumed to point to a buffer of sufficient size (which may be
|
||||
* calculated: ((srclen + 2)/3)*4) into which the encoded data is placed
|
||||
* (without any termination). If the "dest" parameter is null, a buffer is
|
||||
* allocated from the heap to hold the encoded data, and the result *will*
|
||||
* be terminated with an extra null character. It is the caller's
|
||||
* responsibility to free the result when it is allocated. A null is returned
|
||||
* if the allocation fails.
|
||||
*
|
||||
* NOTE: when calculating ((srclen + 2)/3)*4), first ensure that
|
||||
* srclen <= (PR_UINT32_MAX/4) * 3
|
||||
* to avoid PRUint32 overflow.
|
||||
*/
|
||||
|
||||
PR_EXTERN(char *)
|
||||
PL_Base64Encode
|
||||
(
|
||||
const char *src,
|
||||
PRUint32 srclen,
|
||||
char *dest
|
||||
);
|
||||
|
||||
/*
|
||||
* PL_Base64Decode
|
||||
*
|
||||
* This routine decodes the data pointed to by the "src" parameter using
|
||||
* the base64 algorithm, and returns a pointer to the result. The source
|
||||
* may either include or exclude any trailing '=' characters. If the
|
||||
* "srclen" parameter is not zero, it specifies the length of the source
|
||||
* data. If it is zero, PL_strlen will be used to determine the source
|
||||
* length. If the "dest" parameter is not null, it is assumed to point to
|
||||
* a buffer of sufficient size (which may be calculated: (srclen * 3)/4
|
||||
* when srclen includes the '=' characters) into which the decoded data
|
||||
* is placed (without any termination). If the "dest" parameter is null,
|
||||
* a buffer is allocated from the heap to hold the decoded data, and the
|
||||
* result *will* be terminated with an extra null character. It is the
|
||||
* caller's responsibility to free the result when it is allocated. A null
|
||||
* is retuned if the allocation fails, or if the source is not well-coded.
|
||||
*
|
||||
* NOTE: when calculating (srclen * 3)/4, first ensure that
|
||||
* srclen <= PR_UINT32_MAX/3
|
||||
* to avoid PRUint32 overflow. Alternatively, calculate
|
||||
* (srclen/4) * 3 + ((srclen%4) * 3)/4
|
||||
* which is equivalent but doesn't overflow for any value of srclen.
|
||||
*/
|
||||
|
||||
PR_EXTERN(char *)
|
||||
PL_Base64Decode
|
||||
(
|
||||
const char *src,
|
||||
PRUint32 srclen,
|
||||
char *dest
|
||||
);
|
||||
|
||||
PR_END_EXTERN_C
|
||||
|
||||
#endif /* _plbase64_h */
|
||||
34
nsprpub/lib/libc/include/plerror.h
Normal file
34
nsprpub/lib/libc/include/plerror.h
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
/*
|
||||
** File: plerror.h
|
||||
** Description: Simple routine to print translate the calling thread's
|
||||
** error numbers and print them.
|
||||
*/
|
||||
|
||||
#if defined(PLERROR_H)
|
||||
#else
|
||||
#define PLERROR_H
|
||||
|
||||
#include "prio.h"
|
||||
#include "prtypes.h"
|
||||
|
||||
PR_BEGIN_EXTERN_C
|
||||
/*
|
||||
** Print the messages to "syserr" prepending 'msg' if not NULL.
|
||||
*/
|
||||
PR_EXTERN(void) PL_PrintError(const char *msg);
|
||||
|
||||
/*
|
||||
** Print the messages to specified output file prepending 'msg' if not NULL.
|
||||
*/
|
||||
PR_EXTERN(void) PL_FPrintError(PRFileDesc *output, const char *msg);
|
||||
|
||||
PR_END_EXTERN_C
|
||||
|
||||
#endif /* defined(PLERROR_H) */
|
||||
|
||||
/* plerror.h */
|
||||
125
nsprpub/lib/libc/include/plgetopt.h
Normal file
125
nsprpub/lib/libc/include/plgetopt.h
Normal file
|
|
@ -0,0 +1,125 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
/*
|
||||
** File: plgetopt.h
|
||||
** Description: utilities to parse argc/argv
|
||||
*/
|
||||
|
||||
#if defined(PLGETOPT_H_)
|
||||
#else
|
||||
#define PLGETOPT_H_
|
||||
|
||||
#include "prtypes.h"
|
||||
|
||||
PR_BEGIN_EXTERN_C
|
||||
|
||||
typedef struct PLOptionInternal PLOptionInternal;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
PL_OPT_OK, /* all's well with the option */
|
||||
PL_OPT_EOL, /* end of options list */
|
||||
PL_OPT_BAD /* invalid option (and value) */
|
||||
} PLOptStatus;
|
||||
|
||||
typedef struct PLLongOpt
|
||||
{
|
||||
const char * longOptName; /* long option name string */
|
||||
PRIntn longOption; /* value put in PLOptState for this option. */
|
||||
PRBool valueRequired; /* If option name not followed by '=', */
|
||||
/* value is the next argument from argv. */
|
||||
} PLLongOpt;
|
||||
|
||||
typedef struct PLOptState
|
||||
{
|
||||
char option; /* the name of the option */
|
||||
const char *value; /* the value of that option | NULL */
|
||||
|
||||
PLOptionInternal *internal; /* private processing state */
|
||||
|
||||
PRIntn longOption; /* value from PLLongOpt put here */
|
||||
PRIntn longOptIndex; /* index into caller's array of PLLongOpts */
|
||||
} PLOptState;
|
||||
|
||||
/*
|
||||
* PL_CreateOptState
|
||||
*
|
||||
* The argument "options" points to a string of single-character option
|
||||
* names. Option names that may have an option argument value must be
|
||||
* followed immediately by a ':' character.
|
||||
*/
|
||||
PR_EXTERN(PLOptState*) PL_CreateOptState(
|
||||
PRIntn argc, char **argv, const char *options);
|
||||
|
||||
/*
|
||||
* PL_CreateLongOptState
|
||||
*
|
||||
* Alternative to PL_CreateOptState.
|
||||
* Allows caller to specify BOTH a string of single-character option names,
|
||||
* AND an array of structures describing "long" (keyword) option names.
|
||||
* The array is terminated by a structure in which longOptName is NULL.
|
||||
* Long option values (arguments) may always be given as "--name=value".
|
||||
* If PLLongOpt.valueRequired is not PR_FALSE, and the option name was not
|
||||
* followed by '=' then the next argument from argv is taken as the value.
|
||||
*/
|
||||
PR_EXTERN(PLOptState*) PL_CreateLongOptState(
|
||||
PRIntn argc, char **argv, const char *options,
|
||||
const PLLongOpt *longOpts);
|
||||
/*
|
||||
* PL_DestroyOptState
|
||||
*
|
||||
* Call this to destroy the PLOptState returned from PL_CreateOptState or
|
||||
* PL_CreateLongOptState.
|
||||
*/
|
||||
PR_EXTERN(void) PL_DestroyOptState(PLOptState *opt);
|
||||
|
||||
/*
|
||||
* PL_GetNextOpt
|
||||
*
|
||||
* When this function returns PL_OPT_OK,
|
||||
* - opt->option will hold the single-character option name that was parsed,
|
||||
* or zero.
|
||||
* When opt->option is zero, the token parsed was either a "long" (keyword)
|
||||
* option or a positional parameter.
|
||||
* For a positional parameter,
|
||||
* - opt->longOptIndex will contain -1, and
|
||||
* - opt->value will point to the positional parameter string.
|
||||
* For a long option name,
|
||||
* - opt->longOptIndex will contain the non-negative index of the
|
||||
* PLLongOpt structure in the caller's array of PLLongOpt structures
|
||||
* corresponding to the long option name, and
|
||||
* For a single-character or long option,
|
||||
* - opt->longOption will contain the value of the single-character option
|
||||
* name, or the value of the longOption from the PLLongOpt structure
|
||||
* for that long option. See notes below.
|
||||
* - opt->value will point to the argument option string, or will
|
||||
* be NULL if option does not require argument. If option requires
|
||||
* argument but it is not provided, PL_OPT_BAD is returned.
|
||||
* When opt->option is non-zero,
|
||||
* - opt->longOptIndex will be -1
|
||||
* When this function returns PL_OPT_EOL, or PL_OPT_BAD, the contents of
|
||||
* opt are undefined.
|
||||
*
|
||||
* Notes: It is possible to ignore opt->option, and always look at
|
||||
* opt->longOption instead. opt->longOption will contain the same value
|
||||
* as opt->option for single-character option names, and will contain the
|
||||
* value of longOption from the PLLongOpt structure for long option names.
|
||||
* This means that it is possible to equivalence long option names to
|
||||
* single character names by giving the longOption in the PLLongOpt struct
|
||||
* the same value as the single-character option name.
|
||||
* For long options that are NOT intended to be equivalent to any single-
|
||||
* character option, the longOption value should be chosen to not match
|
||||
* any possible single character name. It might be advisable to choose
|
||||
* longOption values greater than 0xff for such long options.
|
||||
*/
|
||||
PR_EXTERN(PLOptStatus) PL_GetNextOpt(PLOptState *opt);
|
||||
|
||||
PR_END_EXTERN_C
|
||||
|
||||
#endif /* defined(PLGETOPT_H_) */
|
||||
|
||||
/* plgetopt.h */
|
||||
|
||||
437
nsprpub/lib/libc/include/plstr.h
Normal file
437
nsprpub/lib/libc/include/plstr.h
Normal file
|
|
@ -0,0 +1,437 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef _plstr_h
|
||||
#define _plstr_h
|
||||
|
||||
/*
|
||||
* plstr.h
|
||||
*
|
||||
* This header file exports the API to the NSPR portable library or string-
|
||||
* handling functions.
|
||||
*
|
||||
* This API was not designed as an "optimal" or "ideal" string library; it
|
||||
* was based on the good ol' unix string.3 functions, and was written to
|
||||
*
|
||||
* 1) replace the libc functions, for cross-platform consistency,
|
||||
* 2) complete the API on platforms lacking common functions (e.g.,
|
||||
* strcase*), and
|
||||
* 3) to implement some obvious "closure" functions that I've seen
|
||||
* people hacking around in our code.
|
||||
*
|
||||
* Point number three largely means that most functions have an "strn"
|
||||
* limited-length version, and all comparison routines have a non-case-
|
||||
* sensitive version available.
|
||||
*/
|
||||
|
||||
#include "prtypes.h"
|
||||
|
||||
PR_BEGIN_EXTERN_C
|
||||
/*
|
||||
* PL_strlen
|
||||
*
|
||||
* Returns the length of the provided string, not including the trailing '\0'.
|
||||
*/
|
||||
|
||||
PR_EXTERN(PRUint32)
|
||||
PL_strlen(const char *str);
|
||||
|
||||
/*
|
||||
* PL_strnlen
|
||||
*
|
||||
* Returns the length of the provided string, not including the trailing '\0',
|
||||
* up to the indicated maximum. The string will not be examined beyond the
|
||||
* maximum; if no terminating '\0' is found, the maximum will be returned.
|
||||
*/
|
||||
|
||||
PR_EXTERN(PRUint32)
|
||||
PL_strnlen(const char *str, PRUint32 max);
|
||||
|
||||
/*
|
||||
* PL_strcpy
|
||||
*
|
||||
* Copies the source string, up to and including the trailing '\0', into the
|
||||
* destination buffer. It does not (can not) verify that the destination
|
||||
* buffer is large enough. It returns the "dest" argument.
|
||||
*/
|
||||
|
||||
PR_EXTERN(char *)
|
||||
PL_strcpy(char *dest, const char *src);
|
||||
|
||||
/*
|
||||
* PL_strncpy
|
||||
*
|
||||
* Copies the source string into the destination buffer, up to and including
|
||||
* the trailing '\0' or up to and including the max'th character, whichever
|
||||
* comes first. It does not (can not) verify that the destination buffer is
|
||||
* large enough. If the source string is longer than the maximum length,
|
||||
* the result will *not* be null-terminated (JLRU).
|
||||
*/
|
||||
|
||||
PR_EXTERN(char *)
|
||||
PL_strncpy(char *dest, const char *src, PRUint32 max);
|
||||
|
||||
/*
|
||||
* PL_strncpyz
|
||||
*
|
||||
* Copies the source string into the destination buffer, up to and including
|
||||
* the trailing '\0' or up but not including the max'th character, whichever
|
||||
* comes first. It does not (can not) verify that the destination buffer is
|
||||
* large enough. The destination string is always terminated with a '\0',
|
||||
* unlike the traditional libc implementation. It returns the "dest" argument.
|
||||
*
|
||||
* NOTE: If you call this with a source "abcdefg" and a max of 5, the
|
||||
* destination will end up with "abcd\0" (i.e., its strlen length will be 4)!
|
||||
*
|
||||
* This means you can do this:
|
||||
*
|
||||
* char buffer[ SOME_SIZE ];
|
||||
* PL_strncpyz(buffer, src, sizeof(buffer));
|
||||
*
|
||||
* and the result will be properly terminated.
|
||||
*/
|
||||
|
||||
PR_EXTERN(char *)
|
||||
PL_strncpyz(char *dest, const char *src, PRUint32 max);
|
||||
|
||||
/*
|
||||
* PL_strdup
|
||||
*
|
||||
* Returns a pointer to a malloc'd extent of memory containing a duplicate
|
||||
* of the argument string. The size of the allocated extent is one greater
|
||||
* than the length of the argument string, because of the terminator. A
|
||||
* null argument, like a zero-length argument, will result in a pointer to
|
||||
* a one-byte extent containing the null value. This routine returns null
|
||||
* upon malloc failure.
|
||||
*/
|
||||
|
||||
PR_EXTERN(char *)
|
||||
PL_strdup(const char *s);
|
||||
|
||||
/*
|
||||
* PL_strfree
|
||||
*
|
||||
* Free memory allocated by PL_strdup
|
||||
*/
|
||||
|
||||
PR_EXTERN(void)
|
||||
PL_strfree(char *s);
|
||||
|
||||
/*
|
||||
* PL_strndup
|
||||
*
|
||||
* Returns a pointer to a malloc'd extent of memory containing a duplicate
|
||||
* of the argument string, up to the maximum specified. If the argument
|
||||
* string has a length greater than the value of the specified maximum, the
|
||||
* return value will be a pointer to an extent of memory of length one
|
||||
* greater than the maximum specified. A null string, a zero-length string,
|
||||
* or a zero maximum will all result in a pointer to a one-byte extent
|
||||
* containing the null value. This routine returns null upon malloc failure.
|
||||
*/
|
||||
|
||||
PR_EXTERN(char *)
|
||||
PL_strndup(const char *s, PRUint32 max);
|
||||
|
||||
/*
|
||||
* PL_strcat
|
||||
*
|
||||
* Appends a copy of the string pointed to by the second argument to the
|
||||
* end of the string pointed to by the first. The destination buffer is
|
||||
* not (can not be) checked for sufficient size. A null destination
|
||||
* argument returns null; otherwise, the first argument is returned.
|
||||
*/
|
||||
|
||||
PR_EXTERN(char *)
|
||||
PL_strcat(char *dst, const char *src);
|
||||
|
||||
/*
|
||||
* PL_strncat
|
||||
*
|
||||
* Appends a copy of the string pointed to by the second argument, up to
|
||||
* the maximum size specified, to the end of the string pointed to by the
|
||||
* first. The destination buffer is not (can not be) checked for sufficient
|
||||
* size. A null destination argument returns null; otherwise, the first
|
||||
* argument is returned. If the maximum size limits the copy, then the
|
||||
* result will *not* be null-terminated (JLRU). A null destination
|
||||
* returns null; otherwise, the destination argument is returned.
|
||||
*/
|
||||
|
||||
PR_EXTERN(char *)
|
||||
PL_strncat(char *dst, const char *src, PRUint32 max);
|
||||
|
||||
/*
|
||||
* PL_strcatn
|
||||
*
|
||||
* Appends a copy of the string pointed to by the third argument, to the
|
||||
* end of the string pointed to by the first. The second argument specifies
|
||||
* the maximum size of the destination buffer, including the null termination.
|
||||
* If the existing string in dst is longer than the max, no action is taken.
|
||||
* The resulting string will be null-terminated. A null destination returns
|
||||
* null; otherwise, the destination argument is returned.
|
||||
*/
|
||||
|
||||
PR_EXTERN(char *)
|
||||
PL_strcatn(char *dst, PRUint32 max, const char *src);
|
||||
|
||||
/*
|
||||
* PL_strcmp
|
||||
*
|
||||
* Returns an integer, the sign of which -- positive, zero, or negative --
|
||||
* reflects the lexical sorting order of the two strings indicated. The
|
||||
* result is positive if the first string comes after the second. The
|
||||
* NSPR implementation is not i18n.
|
||||
*/
|
||||
|
||||
PR_EXTERN(PRIntn)
|
||||
PL_strcmp(const char *a, const char *b);
|
||||
|
||||
/*
|
||||
* PL_strncmp
|
||||
*
|
||||
* Returns an integer, the sign of which -- positive, zero, or negative --
|
||||
* reflects the lexical sorting order of the two strings indicated, up to
|
||||
* the maximum specified. The result is positive if the first string comes
|
||||
* after the second. The NSPR implementation is not i18n. If the maximum
|
||||
* is zero, only the existance or non-existance (pointer is null) of the
|
||||
* strings is compared.
|
||||
*/
|
||||
|
||||
PR_EXTERN(PRIntn)
|
||||
PL_strncmp(const char *a, const char *b, PRUint32 max);
|
||||
|
||||
/*
|
||||
* PL_strcasecmp
|
||||
*
|
||||
* Returns an integer, the sign of which -- positive, zero or negative --
|
||||
* reflects the case-insensitive lexical sorting order of the two strings
|
||||
* indicated. The result is positive if the first string comes after the
|
||||
* second. The NSPR implementation is not i18n.
|
||||
*/
|
||||
|
||||
PR_EXTERN(PRIntn)
|
||||
PL_strcasecmp(const char *a, const char *b);
|
||||
|
||||
/*
|
||||
* PL_strncasecmp
|
||||
*
|
||||
* Returns an integer, the sign of which -- positive, zero or negative --
|
||||
* reflects the case-insensitive lexical sorting order of the first n characters
|
||||
* of the two strings indicated. The result is positive if the first string comes
|
||||
* after the second. The NSPR implementation is not i18n.
|
||||
*/
|
||||
|
||||
PR_EXTERN(PRIntn)
|
||||
PL_strncasecmp(const char *a, const char *b, PRUint32 max);
|
||||
|
||||
/*
|
||||
* PL_strchr
|
||||
*
|
||||
* Returns a pointer to the first instance of the specified character in the
|
||||
* provided string. It returns null if the character is not found, or if the
|
||||
* provided string is null. The character may be the null character.
|
||||
*/
|
||||
|
||||
PR_EXTERN(char *)
|
||||
PL_strchr(const char *s, char c);
|
||||
|
||||
/*
|
||||
* PL_strrchr
|
||||
*
|
||||
* Returns a pointer to the last instance of the specified character in the
|
||||
* provided string. It returns null if the character is not found, or if the
|
||||
* provided string is null. The character may be the null character.
|
||||
*/
|
||||
|
||||
PR_EXTERN(char *)
|
||||
PL_strrchr(const char *s, char c);
|
||||
|
||||
/*
|
||||
* PL_strnchr
|
||||
*
|
||||
* Returns a pointer to the first instance of the specified character within the
|
||||
* first n characters of the provided string. It returns null if the character
|
||||
* is not found, or if the provided string is null. The character may be the
|
||||
* null character.
|
||||
*/
|
||||
|
||||
PR_EXTERN(char *)
|
||||
PL_strnchr(const char *s, char c, PRUint32 n);
|
||||
|
||||
/*
|
||||
* PL_strnrchr
|
||||
*
|
||||
* Returns a pointer to the last instance of the specified character within the
|
||||
* first n characters of the provided string. It returns null if the character is
|
||||
* not found, or if the provided string is null. The character may be the null
|
||||
* character.
|
||||
*/
|
||||
|
||||
PR_EXTERN(char *)
|
||||
PL_strnrchr(const char *s, char c, PRUint32 n);
|
||||
|
||||
/*
|
||||
* NOTE: Looking for strcasechr, strcaserchr, strncasechr, or strncaserchr?
|
||||
* Use strpbrk, strprbrk, strnpbrk or strnprbrk.
|
||||
*/
|
||||
|
||||
/*
|
||||
* PL_strpbrk
|
||||
*
|
||||
* Returns a pointer to the first instance in the first string of any character
|
||||
* (not including the terminating null character) of the second string. It returns
|
||||
* null if either string is null.
|
||||
*/
|
||||
|
||||
PR_EXTERN(char *)
|
||||
PL_strpbrk(const char *s, const char *list);
|
||||
|
||||
/*
|
||||
* PL_strprbrk
|
||||
*
|
||||
* Returns a pointer to the last instance in the first string of any character
|
||||
* (not including the terminating null character) of the second string. It returns
|
||||
* null if either string is null.
|
||||
*/
|
||||
|
||||
PR_EXTERN(char *)
|
||||
PL_strprbrk(const char *s, const char *list);
|
||||
|
||||
/*
|
||||
* PL_strnpbrk
|
||||
*
|
||||
* Returns a pointer to the first instance (within the first n characters) of any
|
||||
* character (not including the terminating null character) of the second string.
|
||||
* It returns null if either string is null.
|
||||
*/
|
||||
|
||||
PR_EXTERN(char *)
|
||||
PL_strnpbrk(const char *s, const char *list, PRUint32 n);
|
||||
|
||||
/*
|
||||
* PL_strnprbrk
|
||||
*
|
||||
* Returns a pointer to the last instance (within the first n characters) of any
|
||||
* character (not including the terminating null character) of the second string.
|
||||
* It returns null if either string is null.
|
||||
*/
|
||||
|
||||
PR_EXTERN(char *)
|
||||
PL_strnprbrk(const char *s, const char *list, PRUint32 n);
|
||||
|
||||
/*
|
||||
* PL_strstr
|
||||
*
|
||||
* Returns a pointer to the first instance of the little string within the
|
||||
* big one. It returns null if either string is null.
|
||||
*/
|
||||
|
||||
PR_EXTERN(char *)
|
||||
PL_strstr(const char *big, const char *little);
|
||||
|
||||
/*
|
||||
* PL_strrstr
|
||||
*
|
||||
* Returns a pointer to the last instance of the little string within the big one.
|
||||
* It returns null if either string is null.
|
||||
*/
|
||||
|
||||
PR_EXTERN(char *)
|
||||
PL_strrstr(const char *big, const char *little);
|
||||
|
||||
/*
|
||||
* PL_strnstr
|
||||
*
|
||||
* Returns a pointer to the first instance of the little string within the first
|
||||
* n characters of the big one. It returns null if either string is null. It
|
||||
* returns null if the length of the little string is greater than n.
|
||||
*/
|
||||
|
||||
PR_EXTERN(char *)
|
||||
PL_strnstr(const char *big, const char *little, PRUint32 n);
|
||||
|
||||
/*
|
||||
* PL_strnrstr
|
||||
*
|
||||
* Returns a pointer to the last instance of the little string within the first
|
||||
* n characters of the big one. It returns null if either string is null. It
|
||||
* returns null if the length of the little string is greater than n.
|
||||
*/
|
||||
|
||||
PR_EXTERN(char *)
|
||||
PL_strnrstr(const char *big, const char *little, PRUint32 max);
|
||||
|
||||
/*
|
||||
* PL_strcasestr
|
||||
*
|
||||
* Returns a pointer to the first instance of the little string within the big one,
|
||||
* ignoring case. It returns null if either string is null.
|
||||
*/
|
||||
|
||||
PR_EXTERN(char *)
|
||||
PL_strcasestr(const char *big, const char *little);
|
||||
|
||||
/*
|
||||
* PL_strcaserstr
|
||||
*
|
||||
* Returns a pointer to the last instance of the little string within the big one,
|
||||
* ignoring case. It returns null if either string is null.
|
||||
*/
|
||||
|
||||
PR_EXTERN(char *)
|
||||
PL_strcaserstr(const char *big, const char *little);
|
||||
|
||||
/*
|
||||
* PL_strncasestr
|
||||
*
|
||||
* Returns a pointer to the first instance of the little string within the first
|
||||
* n characters of the big one, ignoring case. It returns null if either string is
|
||||
* null. It returns null if the length of the little string is greater than n.
|
||||
*/
|
||||
|
||||
PR_EXTERN(char *)
|
||||
PL_strncasestr(const char *big, const char *little, PRUint32 max);
|
||||
|
||||
/*
|
||||
* PL_strncaserstr
|
||||
*
|
||||
* Returns a pointer to the last instance of the little string within the first
|
||||
* n characters of the big one, ignoring case. It returns null if either string is
|
||||
* null. It returns null if the length of the little string is greater than n.
|
||||
*/
|
||||
|
||||
PR_EXTERN(char *)
|
||||
PL_strncaserstr(const char *big, const char *little, PRUint32 max);
|
||||
|
||||
/*
|
||||
* PL_strtok_r
|
||||
*
|
||||
* Splits the string s1 into tokens, separated by one or more characters
|
||||
* from the separator string s2. The argument lasts points to a
|
||||
* user-supplied char * pointer in which PL_strtok_r stores information
|
||||
* for it to continue scanning the same string.
|
||||
*
|
||||
* In the first call to PL_strtok_r, s1 points to a string and the value
|
||||
* of *lasts is ignored. PL_strtok_r returns a pointer to the first
|
||||
* token, writes '\0' into the character following the first token, and
|
||||
* updates *lasts.
|
||||
*
|
||||
* In subsequent calls, s1 is null and lasts must stay unchanged from the
|
||||
* previous call. The separator string s2 may be different from call to
|
||||
* call. PL_strtok_r returns a pointer to the next token in s1. When no
|
||||
* token remains in s1, PL_strtok_r returns null.
|
||||
*/
|
||||
|
||||
PR_EXTERN(char *)
|
||||
PL_strtok_r(char *s1, const char *s2, char **lasts);
|
||||
|
||||
/*
|
||||
* Things not (yet?) included: strspn/strcspn, strsep.
|
||||
* memchr, memcmp, memcpy, memccpy, index, rindex, bcmp, bcopy, bzero.
|
||||
* Any and all i18n/l10n stuff.
|
||||
*/
|
||||
|
||||
PR_END_EXTERN_C
|
||||
|
||||
#endif /* _plstr_h */
|
||||
2
nsprpub/lib/libc/src/.cvsignore
Normal file
2
nsprpub/lib/libc/src/.cvsignore
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
Makefile
|
||||
_pl_bld.h
|
||||
152
nsprpub/lib/libc/src/Makefile.in
Normal file
152
nsprpub/lib/libc/src/Makefile.in
Normal file
|
|
@ -0,0 +1,152 @@
|
|||
#
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
|
||||
#! gmake
|
||||
|
||||
MOD_DEPTH = ../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(MOD_DEPTH)/config/autoconf.mk
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
INCLUDES = -I$(dist_includedir)
|
||||
|
||||
CSRCS =\
|
||||
plvrsion.c \
|
||||
strlen.c \
|
||||
strcpy.c \
|
||||
strdup.c \
|
||||
strcase.c \
|
||||
strcat.c \
|
||||
strcmp.c \
|
||||
strchr.c \
|
||||
strpbrk.c \
|
||||
strstr.c \
|
||||
strtok.c \
|
||||
base64.c \
|
||||
plerror.c \
|
||||
plgetopt.c \
|
||||
$(NULL)
|
||||
|
||||
LIBRARY_NAME = plc
|
||||
LIBRARY_VERSION = $(MOD_MAJOR_VERSION)
|
||||
|
||||
RELEASE_LIBS = $(TARGETS)
|
||||
|
||||
ifeq ($(OS_ARCH),WINNT)
|
||||
RES=$(OBJDIR)/plc.res
|
||||
RESNAME=plc.rc
|
||||
endif # WINNT
|
||||
|
||||
ifeq ($(OS_ARCH), AIX)
|
||||
ifeq ($(CLASSIC_NSPR),1)
|
||||
OS_LIBS = -lc
|
||||
else
|
||||
OS_LIBS = -lc_r
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(OS_ARCH),IRIX)
|
||||
OS_LIBS = -lc
|
||||
endif
|
||||
|
||||
ifeq ($(OS_ARCH),SunOS)
|
||||
OS_LIBS = -lc
|
||||
MAPFILE = $(OBJDIR)/plcmap.sun
|
||||
GARBAGE += $(MAPFILE)
|
||||
ifdef NS_USE_GCC
|
||||
ifdef GCC_USE_GNU_LD
|
||||
MKSHLIB += -Wl,--version-script,$(MAPFILE)
|
||||
else
|
||||
MKSHLIB += -Wl,-M,$(MAPFILE)
|
||||
endif
|
||||
else
|
||||
MKSHLIB += -M $(MAPFILE)
|
||||
endif
|
||||
# The -R '$ORIGIN' linker option instructs this library to search for its
|
||||
# dependencies in the same directory where it resides.
|
||||
MKSHLIB += -R '$$ORIGIN'
|
||||
endif
|
||||
|
||||
ifeq ($(OS_ARCH),OS2)
|
||||
MAPFILE = $(OBJDIR)/$(LIBRARY_NAME)$(LIBRARY_VERSION).def
|
||||
GARBAGE += $(MAPFILE)
|
||||
MKSHLIB += $(MAPFILE)
|
||||
endif
|
||||
|
||||
EXTRA_LIBS = $(LIBNSPR)
|
||||
|
||||
# On SCOOS, we can't link with extra libraries when
|
||||
# we build a shared library. If we do so, the linker doesn't
|
||||
# complain, but we would run into weird problems at run-time.
|
||||
# Therefore on these platforms, we link just the .o files.
|
||||
ifeq ($(OS_ARCH),SCOOS)
|
||||
EXTRA_LIBS =
|
||||
endif
|
||||
|
||||
ifdef RESOLVE_LINK_SYMBOLS
|
||||
EXTRA_LIBS += $(OS_LIBS)
|
||||
endif
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
#
|
||||
# Version information generation (begin)
|
||||
#
|
||||
ECHO = echo
|
||||
TINC = $(OBJDIR)/_pl_bld.h
|
||||
PROD = $(notdir $(SHARED_LIBRARY))
|
||||
NOW = $(MOD_DEPTH)/config/$(OBJDIR)/now
|
||||
SH_DATE = $(shell date "+%Y-%m-%d %T")
|
||||
SH_NOW = $(shell $(NOW))
|
||||
|
||||
ifeq ($(NS_USE_GCC)_$(OS_ARCH),_WINNT)
|
||||
SUF = i64
|
||||
else
|
||||
SUF = LL
|
||||
endif
|
||||
|
||||
GARBAGE += $(TINC)
|
||||
|
||||
$(TINC):
|
||||
@$(MAKE_OBJDIR)
|
||||
@$(ECHO) '#define _BUILD_STRING "$(SH_DATE)"' > $(TINC)
|
||||
@if test ! -z "$(SH_NOW)"; then \
|
||||
$(ECHO) '#define _BUILD_TIME $(SH_NOW)$(SUF)' >> $(TINC); \
|
||||
else \
|
||||
true; \
|
||||
fi
|
||||
@$(ECHO) '#define _PRODUCTION "$(PROD)"' >> $(TINC)
|
||||
|
||||
|
||||
$(OBJDIR)/plvrsion.$(OBJ_SUFFIX): plvrsion.c $(TINC)
|
||||
ifeq ($(NS_USE_GCC)_$(OS_ARCH),_WINNT)
|
||||
$(CC) -Fo$@ -c $(CFLAGS) -I$(OBJDIR) $<
|
||||
else
|
||||
$(CC) -o $@ -c $(CFLAGS) -I$(OBJDIR) $<
|
||||
endif
|
||||
#
|
||||
# Version information generation (end)
|
||||
#
|
||||
|
||||
#
|
||||
# The Client build wants the shared libraries in $(dist_bindir),
|
||||
# so we also install them there.
|
||||
#
|
||||
|
||||
export:: $(TARGETS)
|
||||
$(INSTALL) -m 444 $(TARGETS) $(dist_libdir)
|
||||
ifdef SHARED_LIBRARY
|
||||
ifeq ($(OS_ARCH),HP-UX)
|
||||
$(INSTALL) -m 755 $(SHARED_LIBRARY) $(dist_libdir)
|
||||
$(INSTALL) -m 755 $(SHARED_LIBRARY) $(dist_bindir)
|
||||
else
|
||||
$(INSTALL) -m 444 $(SHARED_LIBRARY) $(dist_bindir)
|
||||
endif
|
||||
endif
|
||||
20
nsprpub/lib/libc/src/README
Normal file
20
nsprpub/lib/libc/src/README
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
NSPR 2.0 libc functions
|
||||
-----------------------
|
||||
|
||||
Last edited: AOF 04 March 1997
|
||||
|
||||
This directory contains various libc-types of functions. All functions in
|
||||
this directory are platform independent, thread friendly (both safe and
|
||||
efficient). They are contributed from various sources, though the contri-
|
||||
butions are monitored by the NSPR group (mailto:freier).
|
||||
|
||||
All API items exported by these functions will contain the same three
|
||||
character prefix, "PL_" (Portable Library). Internal function names
|
||||
that are not exported (static) are of little concern, though some caution
|
||||
must be used on those elements that are 'extern' but not really intended
|
||||
to be part of the API. Those should all have a prefix of "_PL_" (is that
|
||||
legal?).
|
||||
|
||||
The responsibility for contributions in this area are distributed among
|
||||
all interested parties.
|
||||
|
||||
416
nsprpub/lib/libc/src/base64.c
Normal file
416
nsprpub/lib/libc/src/base64.c
Normal file
|
|
@ -0,0 +1,416 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "plbase64.h"
|
||||
#include "prlog.h" /* For PR_NOT_REACHED */
|
||||
#include "prmem.h" /* for malloc / PR_MALLOC */
|
||||
|
||||
#include <string.h> /* for strlen */
|
||||
|
||||
static unsigned char *base = (unsigned char *)"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||
|
||||
static void
|
||||
encode3to4
|
||||
(
|
||||
const unsigned char *src,
|
||||
unsigned char *dest
|
||||
)
|
||||
{
|
||||
PRUint32 b32 = (PRUint32)0;
|
||||
PRIntn i, j = 18;
|
||||
|
||||
for( i = 0; i < 3; i++ )
|
||||
{
|
||||
b32 <<= 8;
|
||||
b32 |= (PRUint32)src[i];
|
||||
}
|
||||
|
||||
for( i = 0; i < 4; i++ )
|
||||
{
|
||||
dest[i] = base[ (PRUint32)((b32>>j) & 0x3F) ];
|
||||
j -= 6;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void
|
||||
encode2to4
|
||||
(
|
||||
const unsigned char *src,
|
||||
unsigned char *dest
|
||||
)
|
||||
{
|
||||
dest[0] = base[ (PRUint32)((src[0]>>2) & 0x3F) ];
|
||||
dest[1] = base[ (PRUint32)(((src[0] & 0x03) << 4) | ((src[1] >> 4) & 0x0F)) ];
|
||||
dest[2] = base[ (PRUint32)((src[1] & 0x0F) << 2) ];
|
||||
dest[3] = (unsigned char)'=';
|
||||
return;
|
||||
}
|
||||
|
||||
static void
|
||||
encode1to4
|
||||
(
|
||||
const unsigned char *src,
|
||||
unsigned char *dest
|
||||
)
|
||||
{
|
||||
dest[0] = base[ (PRUint32)((src[0]>>2) & 0x3F) ];
|
||||
dest[1] = base[ (PRUint32)((src[0] & 0x03) << 4) ];
|
||||
dest[2] = (unsigned char)'=';
|
||||
dest[3] = (unsigned char)'=';
|
||||
return;
|
||||
}
|
||||
|
||||
static void
|
||||
encode
|
||||
(
|
||||
const unsigned char *src,
|
||||
PRUint32 srclen,
|
||||
unsigned char *dest
|
||||
)
|
||||
{
|
||||
while( srclen >= 3 )
|
||||
{
|
||||
encode3to4(src, dest);
|
||||
src += 3;
|
||||
dest += 4;
|
||||
srclen -= 3;
|
||||
}
|
||||
|
||||
switch( srclen )
|
||||
{
|
||||
case 2:
|
||||
encode2to4(src, dest);
|
||||
break;
|
||||
case 1:
|
||||
encode1to4(src, dest);
|
||||
break;
|
||||
case 0:
|
||||
break;
|
||||
default:
|
||||
PR_NOT_REACHED("coding error");
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* PL_Base64Encode
|
||||
*
|
||||
* If the destination argument is NULL, a return buffer is
|
||||
* allocated, and the data therein will be null-terminated.
|
||||
* If the destination argument is not NULL, it is assumed to
|
||||
* be of sufficient size, and the contents will not be null-
|
||||
* terminated by this routine.
|
||||
*
|
||||
* Returns null if the allocation fails.
|
||||
*/
|
||||
|
||||
PR_IMPLEMENT(char *)
|
||||
PL_Base64Encode
|
||||
(
|
||||
const char *src,
|
||||
PRUint32 srclen,
|
||||
char *dest
|
||||
)
|
||||
{
|
||||
if( 0 == srclen )
|
||||
{
|
||||
size_t len = strlen(src);
|
||||
srclen = len;
|
||||
/* Detect truncation. */
|
||||
if( srclen != len )
|
||||
{
|
||||
return (char *)0;
|
||||
}
|
||||
}
|
||||
|
||||
if( (char *)0 == dest )
|
||||
{
|
||||
PRUint32 destlen;
|
||||
/* Ensure all PRUint32 values stay within range. */
|
||||
if( srclen > (PR_UINT32_MAX/4) * 3 )
|
||||
{
|
||||
return (char *)0;
|
||||
}
|
||||
destlen = ((srclen + 2)/3) * 4;
|
||||
dest = (char *)PR_MALLOC(destlen + 1);
|
||||
if( (char *)0 == dest )
|
||||
{
|
||||
return (char *)0;
|
||||
}
|
||||
dest[ destlen ] = (char)0; /* null terminate */
|
||||
}
|
||||
|
||||
encode((const unsigned char *)src, srclen, (unsigned char *)dest);
|
||||
return dest;
|
||||
}
|
||||
|
||||
static PRInt32
|
||||
codetovalue
|
||||
(
|
||||
unsigned char c
|
||||
)
|
||||
{
|
||||
if( (c >= (unsigned char)'A') && (c <= (unsigned char)'Z') )
|
||||
{
|
||||
return (PRInt32)(c - (unsigned char)'A');
|
||||
}
|
||||
else if( (c >= (unsigned char)'a') && (c <= (unsigned char)'z') )
|
||||
{
|
||||
return ((PRInt32)(c - (unsigned char)'a') +26);
|
||||
}
|
||||
else if( (c >= (unsigned char)'0') && (c <= (unsigned char)'9') )
|
||||
{
|
||||
return ((PRInt32)(c - (unsigned char)'0') +52);
|
||||
}
|
||||
else if( (unsigned char)'+' == c )
|
||||
{
|
||||
return (PRInt32)62;
|
||||
}
|
||||
else if( (unsigned char)'/' == c )
|
||||
{
|
||||
return (PRInt32)63;
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
static PRStatus
|
||||
decode4to3
|
||||
(
|
||||
const unsigned char *src,
|
||||
unsigned char *dest
|
||||
)
|
||||
{
|
||||
PRUint32 b32 = (PRUint32)0;
|
||||
PRInt32 bits;
|
||||
PRIntn i;
|
||||
|
||||
for( i = 0; i < 4; i++ )
|
||||
{
|
||||
bits = codetovalue(src[i]);
|
||||
if( bits < 0 )
|
||||
{
|
||||
return PR_FAILURE;
|
||||
}
|
||||
|
||||
b32 <<= 6;
|
||||
b32 |= bits;
|
||||
}
|
||||
|
||||
dest[0] = (unsigned char)((b32 >> 16) & 0xFF);
|
||||
dest[1] = (unsigned char)((b32 >> 8) & 0xFF);
|
||||
dest[2] = (unsigned char)((b32 ) & 0xFF);
|
||||
|
||||
return PR_SUCCESS;
|
||||
}
|
||||
|
||||
static PRStatus
|
||||
decode3to2
|
||||
(
|
||||
const unsigned char *src,
|
||||
unsigned char *dest
|
||||
)
|
||||
{
|
||||
PRUint32 b32 = (PRUint32)0;
|
||||
PRInt32 bits;
|
||||
PRUint32 ubits;
|
||||
|
||||
bits = codetovalue(src[0]);
|
||||
if( bits < 0 )
|
||||
{
|
||||
return PR_FAILURE;
|
||||
}
|
||||
|
||||
b32 = (PRUint32)bits;
|
||||
b32 <<= 6;
|
||||
|
||||
bits = codetovalue(src[1]);
|
||||
if( bits < 0 )
|
||||
{
|
||||
return PR_FAILURE;
|
||||
}
|
||||
|
||||
b32 |= (PRUint32)bits;
|
||||
b32 <<= 4;
|
||||
|
||||
bits = codetovalue(src[2]);
|
||||
if( bits < 0 )
|
||||
{
|
||||
return PR_FAILURE;
|
||||
}
|
||||
|
||||
ubits = (PRUint32)bits;
|
||||
b32 |= (ubits >> 2);
|
||||
|
||||
dest[0] = (unsigned char)((b32 >> 8) & 0xFF);
|
||||
dest[1] = (unsigned char)((b32 ) & 0xFF);
|
||||
|
||||
return PR_SUCCESS;
|
||||
}
|
||||
|
||||
static PRStatus
|
||||
decode2to1
|
||||
(
|
||||
const unsigned char *src,
|
||||
unsigned char *dest
|
||||
)
|
||||
{
|
||||
PRUint32 b32;
|
||||
PRUint32 ubits;
|
||||
PRInt32 bits;
|
||||
|
||||
bits = codetovalue(src[0]);
|
||||
if( bits < 0 )
|
||||
{
|
||||
return PR_FAILURE;
|
||||
}
|
||||
|
||||
ubits = (PRUint32)bits;
|
||||
b32 = (ubits << 2);
|
||||
|
||||
bits = codetovalue(src[1]);
|
||||
if( bits < 0 )
|
||||
{
|
||||
return PR_FAILURE;
|
||||
}
|
||||
|
||||
ubits = (PRUint32)bits;
|
||||
b32 |= (ubits >> 4);
|
||||
|
||||
dest[0] = (unsigned char)b32;
|
||||
|
||||
return PR_SUCCESS;
|
||||
}
|
||||
|
||||
static PRStatus
|
||||
decode
|
||||
(
|
||||
const unsigned char *src,
|
||||
PRUint32 srclen,
|
||||
unsigned char *dest
|
||||
)
|
||||
{
|
||||
PRStatus rv;
|
||||
|
||||
while( srclen >= 4 )
|
||||
{
|
||||
rv = decode4to3(src, dest);
|
||||
if( PR_SUCCESS != rv )
|
||||
{
|
||||
return PR_FAILURE;
|
||||
}
|
||||
|
||||
src += 4;
|
||||
dest += 3;
|
||||
srclen -= 4;
|
||||
}
|
||||
|
||||
switch( srclen )
|
||||
{
|
||||
case 3:
|
||||
rv = decode3to2(src, dest);
|
||||
break;
|
||||
case 2:
|
||||
rv = decode2to1(src, dest);
|
||||
break;
|
||||
case 1:
|
||||
rv = PR_FAILURE;
|
||||
break;
|
||||
case 0:
|
||||
rv = PR_SUCCESS;
|
||||
break;
|
||||
default:
|
||||
PR_NOT_REACHED("coding error");
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
/*
|
||||
* PL_Base64Decode
|
||||
*
|
||||
* If the destination argument is NULL, a return buffer is
|
||||
* allocated and the data therein will be null-terminated.
|
||||
* If the destination argument is not null, it is assumed
|
||||
* to be of sufficient size, and the data will not be null-
|
||||
* terminated by this routine.
|
||||
*
|
||||
* Returns null if the allocation fails, or if the source string is
|
||||
* not well-formed.
|
||||
*/
|
||||
|
||||
PR_IMPLEMENT(char *)
|
||||
PL_Base64Decode
|
||||
(
|
||||
const char *src,
|
||||
PRUint32 srclen,
|
||||
char *dest
|
||||
)
|
||||
{
|
||||
PRStatus status;
|
||||
PRBool allocated = PR_FALSE;
|
||||
|
||||
if( (char *)0 == src )
|
||||
{
|
||||
return (char *)0;
|
||||
}
|
||||
|
||||
if( 0 == srclen )
|
||||
{
|
||||
size_t len = strlen(src);
|
||||
srclen = len;
|
||||
/* Detect truncation. */
|
||||
if( srclen != len )
|
||||
{
|
||||
return (char *)0;
|
||||
}
|
||||
}
|
||||
|
||||
if( srclen && (0 == (srclen & 3)) )
|
||||
{
|
||||
if( (char)'=' == src[ srclen-1 ] )
|
||||
{
|
||||
if( (char)'=' == src[ srclen-2 ] )
|
||||
{
|
||||
srclen -= 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
srclen -= 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( (char *)0 == dest )
|
||||
{
|
||||
/* The following computes ((srclen * 3) / 4) without overflow. */
|
||||
PRUint32 destlen = (srclen / 4) * 3 + ((srclen % 4) * 3) / 4;
|
||||
dest = (char *)PR_MALLOC(destlen + 1);
|
||||
if( (char *)0 == dest )
|
||||
{
|
||||
return (char *)0;
|
||||
}
|
||||
dest[ destlen ] = (char)0; /* null terminate */
|
||||
allocated = PR_TRUE;
|
||||
}
|
||||
|
||||
status = decode((const unsigned char *)src, srclen, (unsigned char *)dest);
|
||||
if( PR_SUCCESS != status )
|
||||
{
|
||||
if( PR_TRUE == allocated )
|
||||
{
|
||||
PR_DELETE(dest);
|
||||
}
|
||||
|
||||
return (char *)0;
|
||||
}
|
||||
|
||||
return dest;
|
||||
}
|
||||
72
nsprpub/lib/libc/src/plc.def
Normal file
72
nsprpub/lib/libc/src/plc.def
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
;+#
|
||||
;+# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
;+# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
;+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
;+#
|
||||
;+# OK, this file is meant to support SUN, LINUX, AIX, OS/2 and WINDOWS
|
||||
;+# 1. For all unix platforms, the string ";-" means "remove this line"
|
||||
;+# 2. For all unix platforms, the string " DATA " will be removed from any
|
||||
;+# line on which it occurs.
|
||||
;+# 3. Lines containing ";+" will have ";+" removed on SUN and LINUX.
|
||||
;+# On AIX, lines containing ";+" will be removed.
|
||||
;+# 4. For all unix platforms, the string ";;" will thave the ";;" removed.
|
||||
;+# 5. For all unix platforms, after the above processing has taken place,
|
||||
;+# all characters after the first ";" on the line will be removed.
|
||||
;+# And for AIX, the first ";" will also be removed.
|
||||
;+# This file is passed directly to windows. Since ';' is a comment, all UNIX
|
||||
;+# directives are hidden behind ";", ";+", and ";-"
|
||||
;+NSPR_4.0 {
|
||||
;+ global:
|
||||
LIBRARY plc4 ;-
|
||||
EXPORTS ;-
|
||||
PL_Base64Decode;
|
||||
PL_Base64Encode;
|
||||
PL_CreateOptState;
|
||||
PL_DestroyOptState;
|
||||
PL_FPrintError;
|
||||
PL_GetNextOpt;
|
||||
PL_PrintError;
|
||||
PL_strcasecmp;
|
||||
PL_strcaserstr;
|
||||
PL_strcasestr;
|
||||
PL_strcat;
|
||||
PL_strcatn;
|
||||
PL_strchr;
|
||||
PL_strcmp;
|
||||
PL_strcpy;
|
||||
PL_strdup;
|
||||
PL_strfree;
|
||||
PL_strlen;
|
||||
PL_strncasecmp;
|
||||
PL_strncaserstr;
|
||||
PL_strncasestr;
|
||||
PL_strncat;
|
||||
PL_strnchr;
|
||||
PL_strncmp;
|
||||
PL_strncpy;
|
||||
PL_strncpyz;
|
||||
PL_strndup;
|
||||
PL_strnlen;
|
||||
PL_strnpbrk;
|
||||
PL_strnprbrk;
|
||||
PL_strnrchr;
|
||||
PL_strnrstr;
|
||||
PL_strnstr;
|
||||
PL_strpbrk;
|
||||
PL_strprbrk;
|
||||
PL_strrchr;
|
||||
PL_strrstr;
|
||||
PL_strstr;
|
||||
libVersionPoint;
|
||||
;+ local: *;
|
||||
;+};
|
||||
;+
|
||||
;+NSPR_4.2 {
|
||||
;+ global:
|
||||
PL_strtok_r;
|
||||
;+} NSPR_4.0;
|
||||
;+
|
||||
;+NSPR_4.7 {
|
||||
;+ global:
|
||||
PL_CreateLongOptState;
|
||||
;+} NSPR_4.2;
|
||||
70
nsprpub/lib/libc/src/plc.rc
Normal file
70
nsprpub/lib/libc/src/plc.rc
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
|
||||
#include "prinit.h"
|
||||
#include <winver.h>
|
||||
|
||||
#define MY_LIBNAME "plc"
|
||||
#define MY_FILEDESCRIPTION "PLC Library"
|
||||
|
||||
#define STRINGIZE(x) #x
|
||||
#define STRINGIZE2(x) STRINGIZE(x)
|
||||
#define PR_VMAJOR_STR STRINGIZE2(PR_VMAJOR)
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define MY_DEBUG_STR " (debug)"
|
||||
#define MY_FILEFLAGS_1 VS_FF_DEBUG
|
||||
#else
|
||||
#define MY_DEBUG_STR ""
|
||||
#define MY_FILEFLAGS_1 0x0L
|
||||
#endif
|
||||
#if PR_BETA
|
||||
#define MY_FILEFLAGS_2 MY_FILEFLAGS_1|VS_FF_PRERELEASE
|
||||
#else
|
||||
#define MY_FILEFLAGS_2 MY_FILEFLAGS_1
|
||||
#endif
|
||||
|
||||
#ifdef WINNT
|
||||
#define MY_FILEOS VOS_NT_WINDOWS32
|
||||
#define MY_INTERNAL_NAME "lib" MY_LIBNAME PR_VMAJOR_STR
|
||||
#else
|
||||
#define MY_FILEOS VOS__WINDOWS32
|
||||
#define MY_INTERNAL_NAME MY_LIBNAME PR_VMAJOR_STR
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Version-information resource
|
||||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION PR_VMAJOR,PR_VMINOR,PR_VPATCH,0
|
||||
PRODUCTVERSION PR_VMAJOR,PR_VMINOR,PR_VPATCH,0
|
||||
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
|
||||
FILEFLAGS MY_FILEFLAGS_2
|
||||
FILEOS MY_FILEOS
|
||||
FILETYPE VFT_DLL
|
||||
FILESUBTYPE 0x0L // not used
|
||||
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040904B0" // Lang=US English, CharSet=Unicode
|
||||
BEGIN
|
||||
VALUE "CompanyName", "Mozilla Foundation\0"
|
||||
VALUE "FileDescription", MY_FILEDESCRIPTION MY_DEBUG_STR "\0"
|
||||
VALUE "FileVersion", PR_VERSION "\0"
|
||||
VALUE "InternalName", MY_INTERNAL_NAME "\0"
|
||||
VALUE "OriginalFilename", MY_INTERNAL_NAME ".dll\0"
|
||||
VALUE "ProductName", "Netscape Portable Runtime\0"
|
||||
VALUE "ProductVersion", PR_VERSION "\0"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x409, 1200
|
||||
END
|
||||
END
|
||||
40
nsprpub/lib/libc/src/plerror.c
Normal file
40
nsprpub/lib/libc/src/plerror.c
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
/*
|
||||
** File:plerror.c
|
||||
** Description: Simple routine to print translate the calling thread's
|
||||
** error numbers and print them to "syserr".
|
||||
*/
|
||||
|
||||
#include "plerror.h"
|
||||
|
||||
#include "prprf.h"
|
||||
#include "prerror.h"
|
||||
|
||||
PR_IMPLEMENT(void) PL_FPrintError(PRFileDesc *fd, const char *msg)
|
||||
{
|
||||
PRErrorCode error = PR_GetError();
|
||||
PRInt32 oserror = PR_GetOSError();
|
||||
const char *name = PR_ErrorToName(error);
|
||||
|
||||
if (NULL != msg) PR_fprintf(fd, "%s: ", msg);
|
||||
if (NULL == name)
|
||||
PR_fprintf(
|
||||
fd, " (%d)OUT OF RANGE, oserror = %d\n", error, oserror);
|
||||
else
|
||||
PR_fprintf(
|
||||
fd, "%s(%d), oserror = %d\n",
|
||||
name, error, oserror);
|
||||
} /* PL_FPrintError */
|
||||
|
||||
PR_IMPLEMENT(void) PL_PrintError(const char *msg)
|
||||
{
|
||||
static PRFileDesc *fd = NULL;
|
||||
if (NULL == fd) fd = PR_GetSpecialFD(PR_StandardError);
|
||||
PL_FPrintError(fd, msg);
|
||||
} /* PL_PrintError */
|
||||
|
||||
/* plerror.c */
|
||||
248
nsprpub/lib/libc/src/plgetopt.c
Normal file
248
nsprpub/lib/libc/src/plgetopt.c
Normal file
|
|
@ -0,0 +1,248 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
/*
|
||||
** File: plgetopt.c
|
||||
** Description: utilities to parse argc/argv
|
||||
*/
|
||||
|
||||
#include "prmem.h"
|
||||
#include "prlog.h"
|
||||
#include "prerror.h"
|
||||
#include "plstr.h"
|
||||
#include "plgetopt.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
static char static_Nul = 0;
|
||||
|
||||
struct PLOptionInternal
|
||||
{
|
||||
const char *options; /* client options list specification */
|
||||
PRIntn argc; /* original number of arguments */
|
||||
char **argv; /* vector of pointers to arguments */
|
||||
PRIntn xargc; /* which one we're processing now */
|
||||
const char *xargv; /* where within *argv[xargc] */
|
||||
PRIntn minus; /* do we already have the '-'? */
|
||||
const PLLongOpt *longOpts; /* Caller's array */
|
||||
PRBool endOfOpts; /* have reached a "--" argument */
|
||||
PRIntn optionsLen; /* is strlen(options) */
|
||||
};
|
||||
|
||||
/*
|
||||
** Create the state in which to parse the tokens.
|
||||
**
|
||||
** argc the sum of the number of options and their values
|
||||
** argv the options and their values
|
||||
** options vector of single character options w/ | w/o ':
|
||||
*/
|
||||
PR_IMPLEMENT(PLOptState*) PL_CreateOptState(
|
||||
PRIntn argc, char **argv, const char *options)
|
||||
{
|
||||
return PL_CreateLongOptState( argc, argv, options, NULL);
|
||||
} /* PL_CreateOptState */
|
||||
|
||||
PR_IMPLEMENT(PLOptState*) PL_CreateLongOptState(
|
||||
PRIntn argc, char **argv, const char *options,
|
||||
const PLLongOpt *longOpts)
|
||||
{
|
||||
PLOptState *opt = NULL;
|
||||
PLOptionInternal *internal;
|
||||
|
||||
if (NULL == options)
|
||||
{
|
||||
PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);
|
||||
return opt;
|
||||
}
|
||||
|
||||
opt = PR_NEWZAP(PLOptState);
|
||||
if (NULL == opt)
|
||||
{
|
||||
PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);
|
||||
return opt;
|
||||
}
|
||||
|
||||
internal = PR_NEW(PLOptionInternal);
|
||||
if (NULL == internal)
|
||||
{
|
||||
PR_DELETE(opt);
|
||||
PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
opt->option = 0;
|
||||
opt->value = NULL;
|
||||
opt->internal = internal;
|
||||
opt->longOption = 0;
|
||||
opt->longOptIndex = -1;
|
||||
|
||||
internal->argc = argc;
|
||||
internal->argv = argv;
|
||||
internal->xargc = 0;
|
||||
internal->xargv = &static_Nul;
|
||||
internal->minus = 0;
|
||||
internal->options = options;
|
||||
internal->longOpts = longOpts;
|
||||
internal->endOfOpts = PR_FALSE;
|
||||
internal->optionsLen = PL_strlen(options);
|
||||
|
||||
return opt;
|
||||
} /* PL_CreateLongOptState */
|
||||
|
||||
/*
|
||||
** Destroy object created by CreateOptState()
|
||||
*/
|
||||
PR_IMPLEMENT(void) PL_DestroyOptState(PLOptState *opt)
|
||||
{
|
||||
PR_DELETE(opt->internal);
|
||||
PR_DELETE(opt);
|
||||
} /* PL_DestroyOptState */
|
||||
|
||||
PR_IMPLEMENT(PLOptStatus) PL_GetNextOpt(PLOptState *opt)
|
||||
{
|
||||
PLOptionInternal *internal = opt->internal;
|
||||
|
||||
opt->longOption = 0;
|
||||
opt->longOptIndex = -1;
|
||||
/*
|
||||
** If the current xarg points to nul, advance to the next
|
||||
** element of the argv vector. If the vector index is equal
|
||||
** to argc, we're out of arguments, so return an EOL.
|
||||
** Note whether the first character of the new argument is
|
||||
** a '-' and skip by it if it is.
|
||||
*/
|
||||
while (0 == *internal->xargv)
|
||||
{
|
||||
internal->xargc += 1;
|
||||
if (internal->xargc >= internal->argc)
|
||||
{
|
||||
opt->option = 0;
|
||||
opt->value = NULL;
|
||||
return PL_OPT_EOL;
|
||||
}
|
||||
internal->xargv = internal->argv[internal->xargc];
|
||||
internal->minus = 0;
|
||||
if (!internal->endOfOpts && ('-' == *internal->xargv))
|
||||
{
|
||||
internal->minus++;
|
||||
internal->xargv++; /* and consume */
|
||||
if ('-' == *internal->xargv && internal->longOpts)
|
||||
{
|
||||
internal->minus++;
|
||||
internal->xargv++;
|
||||
if (0 == *internal->xargv)
|
||||
{
|
||||
internal->endOfOpts = PR_TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** If we already have a '-' or '--' in hand, xargv points to the next
|
||||
** option. See if we can find a match in the list of possible
|
||||
** options supplied.
|
||||
*/
|
||||
if (internal->minus == 2)
|
||||
{
|
||||
char * foundEqual = strchr(internal->xargv,'=');
|
||||
PRIntn optNameLen = foundEqual ? (foundEqual - internal->xargv) :
|
||||
strlen(internal->xargv);
|
||||
const PLLongOpt *longOpt = internal->longOpts;
|
||||
PLOptStatus result = PL_OPT_BAD;
|
||||
|
||||
opt->option = 0;
|
||||
opt->value = NULL;
|
||||
|
||||
for (; longOpt->longOptName; ++longOpt)
|
||||
{
|
||||
if (strncmp(longOpt->longOptName, internal->xargv, optNameLen))
|
||||
continue; /* not a possible match */
|
||||
if (strlen(longOpt->longOptName) != optNameLen)
|
||||
continue; /* not a match */
|
||||
/* option name match */
|
||||
opt->longOptIndex = longOpt - internal->longOpts;
|
||||
opt->longOption = longOpt->longOption;
|
||||
/* value is part of the current argv[] element if = was found */
|
||||
/* note: this sets value even for long options that do not
|
||||
* require option if specified as --long=value */
|
||||
if (foundEqual)
|
||||
{
|
||||
opt->value = foundEqual + 1;
|
||||
}
|
||||
else if (longOpt->valueRequired)
|
||||
{
|
||||
/* value is the next argv[] element, if any */
|
||||
if (internal->xargc + 1 < internal->argc)
|
||||
{
|
||||
opt->value = internal->argv[++(internal->xargc)];
|
||||
}
|
||||
/* missing value */
|
||||
else
|
||||
{
|
||||
break; /* return PL_OPT_BAD */
|
||||
}
|
||||
}
|
||||
result = PL_OPT_OK;
|
||||
break;
|
||||
}
|
||||
internal->xargv = &static_Nul; /* consume this */
|
||||
return result;
|
||||
}
|
||||
if (internal->minus)
|
||||
{
|
||||
PRIntn cop;
|
||||
PRIntn eoo = internal->optionsLen;
|
||||
for (cop = 0; cop < eoo; ++cop)
|
||||
{
|
||||
if (internal->options[cop] == *internal->xargv)
|
||||
{
|
||||
opt->option = *internal->xargv++;
|
||||
opt->longOption = opt->option & 0xff;
|
||||
/*
|
||||
** if options indicates that there's an associated
|
||||
** value, it must be provided, either as part of this
|
||||
** argv[] element or as the next one
|
||||
*/
|
||||
if (':' == internal->options[cop + 1])
|
||||
{
|
||||
/* value is part of the current argv[] element */
|
||||
if (0 != *internal->xargv)
|
||||
{
|
||||
opt->value = internal->xargv;
|
||||
}
|
||||
/* value is the next argv[] element, if any */
|
||||
else if (internal->xargc + 1 < internal->argc)
|
||||
{
|
||||
opt->value = internal->argv[++(internal->xargc)];
|
||||
}
|
||||
/* missing value */
|
||||
else
|
||||
{
|
||||
return PL_OPT_BAD;
|
||||
}
|
||||
|
||||
internal->xargv = &static_Nul;
|
||||
internal->minus = 0;
|
||||
}
|
||||
else
|
||||
opt->value = NULL;
|
||||
return PL_OPT_OK;
|
||||
}
|
||||
}
|
||||
internal->xargv += 1; /* consume that option */
|
||||
return PL_OPT_BAD;
|
||||
}
|
||||
|
||||
/*
|
||||
** No '-', so it must be a standalone value. The option is nul.
|
||||
*/
|
||||
opt->value = internal->argv[internal->xargc];
|
||||
internal->xargv = &static_Nul;
|
||||
opt->option = 0;
|
||||
return PL_OPT_OK;
|
||||
} /* PL_GetNextOpt */
|
||||
|
||||
/* plgetopt.c */
|
||||
93
nsprpub/lib/libc/src/plvrsion.c
Normal file
93
nsprpub/lib/libc/src/plvrsion.c
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "prinit.h"
|
||||
#include "prvrsion.h"
|
||||
|
||||
/************************************************************************/
|
||||
/**************************IDENTITY AND VERSIONING***********************/
|
||||
/************************************************************************/
|
||||
#include "_pl_bld.h"
|
||||
#if !defined(_BUILD_TIME)
|
||||
#ifdef HAVE_LONG_LONG
|
||||
#define _BUILD_TIME 0
|
||||
#else
|
||||
#define _BUILD_TIME {0, 0}
|
||||
#endif
|
||||
#endif
|
||||
#if !defined(_BUILD_STRING)
|
||||
#define _BUILD_STRING ""
|
||||
#endif
|
||||
#if !defined(_PRODUCTION)
|
||||
#define _PRODUCTION ""
|
||||
#endif
|
||||
#if defined(DEBUG)
|
||||
#define _DEBUG_STRING " (debug)"
|
||||
#else
|
||||
#define _DEBUG_STRING ""
|
||||
#endif
|
||||
|
||||
/*
|
||||
* A trick to expand the PR_VMAJOR macro before concatenation.
|
||||
*/
|
||||
#define CONCAT(x, y) x ## y
|
||||
#define CONCAT2(x, y) CONCAT(x, y)
|
||||
#define VERSION_DESC_NAME CONCAT2(prVersionDescription_libplc, PR_VMAJOR)
|
||||
|
||||
PRVersionDescription VERSION_DESC_NAME =
|
||||
{
|
||||
/* version */ 2, /* this is the only one supported */
|
||||
/* buildTime */ _BUILD_TIME, /* usecs since midnight 1/1/1970 GMT */
|
||||
/* buildTimeString */ _BUILD_STRING, /* ditto, but human readable */
|
||||
/* vMajor */ PR_VMAJOR, /* NSPR's version number */
|
||||
/* vMinor */ PR_VMINOR, /* and minor version */
|
||||
/* vPatch */ PR_VPATCH, /* and patch */
|
||||
/* beta */ PR_BETA, /* beta build boolean */
|
||||
#if defined(DEBUG)
|
||||
/* debug */ PR_TRUE, /* a debug build */
|
||||
#else
|
||||
/* debug */ PR_FALSE, /* an optomized build */
|
||||
#endif
|
||||
/* special */ PR_FALSE, /* they're all special, but ... */
|
||||
/* filename */ _PRODUCTION, /* the produced library name */
|
||||
/* description */ "Portable runtime", /* what we are */
|
||||
/* security */ "N/A", /* not applicable here */
|
||||
/* copywrite */ "Copyright (c) 1998 Netscape Communications Corporation. All Rights Reserved",
|
||||
/* comment */ "http://www.mozilla.org/MPL/",
|
||||
/* specialString */ ""
|
||||
};
|
||||
|
||||
#ifdef XP_UNIX
|
||||
|
||||
/*
|
||||
* Version information for the 'ident' and 'what commands
|
||||
*
|
||||
* NOTE: the first component of the concatenated rcsid string
|
||||
* must not end in a '$' to prevent rcs keyword substitution.
|
||||
*/
|
||||
static char rcsid[] = "$Header: NSPR " PR_VERSION _DEBUG_STRING
|
||||
" " _BUILD_STRING " $";
|
||||
static char sccsid[] = "@(#)NSPR " PR_VERSION _DEBUG_STRING
|
||||
" " _BUILD_STRING;
|
||||
|
||||
#endif /* XP_UNIX */
|
||||
|
||||
PR_IMPLEMENT(const PRVersionDescription*) libVersionPoint()
|
||||
{
|
||||
#ifdef XP_UNIX
|
||||
/*
|
||||
* Add dummy references to rcsid and sccsid to prevent them
|
||||
* from being optimized away as unused variables.
|
||||
*/
|
||||
const char *dummy;
|
||||
|
||||
dummy = rcsid;
|
||||
dummy = sccsid;
|
||||
#endif
|
||||
return &VERSION_DESC_NAME;
|
||||
} /* versionEntryPointType */
|
||||
|
||||
/* plvrsion.c */
|
||||
|
||||
174
nsprpub/lib/libc/src/strcase.c
Normal file
174
nsprpub/lib/libc/src/strcase.c
Normal file
|
|
@ -0,0 +1,174 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "plstr.h"
|
||||
#include <string.h>
|
||||
|
||||
static const unsigned char uc[] =
|
||||
{
|
||||
'\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007',
|
||||
'\010', '\011', '\012', '\013', '\014', '\015', '\016', '\017',
|
||||
'\020', '\021', '\022', '\023', '\024', '\025', '\026', '\027',
|
||||
'\030', '\031', '\032', '\033', '\034', '\035', '\036', '\037',
|
||||
' ', '!', '"', '#', '$', '%', '&', '\'',
|
||||
'(', ')', '*', '+', ',', '-', '.', '/',
|
||||
'0', '1', '2', '3', '4', '5', '6', '7',
|
||||
'8', '9', ':', ';', '<', '=', '>', '?',
|
||||
'@', 'A', 'B', 'C', 'D', 'E', 'F', 'G',
|
||||
'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
|
||||
'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
|
||||
'X', 'Y', 'Z', '[', '\\', ']', '^', '_',
|
||||
'`', 'A', 'B', 'C', 'D', 'E', 'F', 'G',
|
||||
'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
|
||||
'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
|
||||
'X', 'Y', 'Z', '{', '|', '}', '~', '\177',
|
||||
0200, 0201, 0202, 0203, 0204, 0205, 0206, 0207,
|
||||
0210, 0211, 0212, 0213, 0214, 0215, 0216, 0217,
|
||||
0220, 0221, 0222, 0223, 0224, 0225, 0226, 0227,
|
||||
0230, 0231, 0232, 0233, 0234, 0235, 0236, 0237,
|
||||
0240, 0241, 0242, 0243, 0244, 0245, 0246, 0247,
|
||||
0250, 0251, 0252, 0253, 0254, 0255, 0256, 0257,
|
||||
0260, 0261, 0262, 0263, 0264, 0265, 0266, 0267,
|
||||
0270, 0271, 0272, 0273, 0274, 0275, 0276, 0277,
|
||||
0300, 0301, 0302, 0303, 0304, 0305, 0306, 0307,
|
||||
0310, 0311, 0312, 0313, 0314, 0315, 0316, 0317,
|
||||
0320, 0321, 0322, 0323, 0324, 0325, 0326, 0327,
|
||||
0330, 0331, 0332, 0333, 0334, 0335, 0336, 0337,
|
||||
0340, 0341, 0342, 0343, 0344, 0345, 0346, 0347,
|
||||
0350, 0351, 0352, 0353, 0354, 0355, 0356, 0357,
|
||||
0360, 0361, 0362, 0363, 0364, 0365, 0366, 0367,
|
||||
0370, 0371, 0372, 0373, 0374, 0375, 0376, 0377
|
||||
};
|
||||
|
||||
PR_IMPLEMENT(PRIntn)
|
||||
PL_strcasecmp(const char *a, const char *b)
|
||||
{
|
||||
const unsigned char *ua = (const unsigned char *)a;
|
||||
const unsigned char *ub = (const unsigned char *)b;
|
||||
|
||||
if( (const char *)0 == a )
|
||||
return ((const char *)0 == b) ? 0 : -1;
|
||||
if( (const char *)0 == b )
|
||||
return 1;
|
||||
|
||||
while( (uc[*ua] == uc[*ub]) && ('\0' != *a) )
|
||||
{
|
||||
a++;
|
||||
ua++;
|
||||
ub++;
|
||||
}
|
||||
|
||||
return (PRIntn)(uc[*ua] - uc[*ub]);
|
||||
}
|
||||
|
||||
PR_IMPLEMENT(PRIntn)
|
||||
PL_strncasecmp(const char *a, const char *b, PRUint32 max)
|
||||
{
|
||||
const unsigned char *ua = (const unsigned char *)a;
|
||||
const unsigned char *ub = (const unsigned char *)b;
|
||||
|
||||
if( (const char *)0 == a )
|
||||
return ((const char *)0 == b) ? 0 : -1;
|
||||
if( (const char *)0 == b )
|
||||
return 1;
|
||||
|
||||
while( max && (uc[*ua] == uc[*ub]) && ('\0' != *a) )
|
||||
{
|
||||
a++;
|
||||
ua++;
|
||||
ub++;
|
||||
max--;
|
||||
}
|
||||
|
||||
if( 0 == max ) return (PRIntn)0;
|
||||
|
||||
return (PRIntn)(uc[*ua] - uc[*ub]);
|
||||
}
|
||||
|
||||
PR_IMPLEMENT(char *)
|
||||
PL_strcasestr(const char *big, const char *little)
|
||||
{
|
||||
PRUint32 ll;
|
||||
|
||||
if( ((const char *)0 == big) || ((const char *)0 == little) ) return (char *)0;
|
||||
if( ((char)0 == *big) || ((char)0 == *little) ) return (char *)0;
|
||||
|
||||
ll = strlen(little);
|
||||
|
||||
for( ; *big; big++ )
|
||||
/* obvious improvement available here */
|
||||
if( 0 == PL_strncasecmp(big, little, ll) )
|
||||
return (char *)big;
|
||||
|
||||
return (char *)0;
|
||||
}
|
||||
|
||||
PR_IMPLEMENT(char *)
|
||||
PL_strcaserstr(const char *big, const char *little)
|
||||
{
|
||||
const char *p;
|
||||
PRUint32 bl, ll;
|
||||
|
||||
if( ((const char *)0 == big) || ((const char *)0 == little) ) return (char *)0;
|
||||
if( ((char)0 == *big) || ((char)0 == *little) ) return (char *)0;
|
||||
|
||||
bl = strlen(big);
|
||||
ll = strlen(little);
|
||||
if( bl < ll ) return (char *)0;
|
||||
p = &big[ bl - ll ];
|
||||
|
||||
for( ; p >= big; p-- )
|
||||
/* obvious improvement available here */
|
||||
if( 0 == PL_strncasecmp(p, little, ll) )
|
||||
return (char *)p;
|
||||
|
||||
return (char *)0;
|
||||
}
|
||||
|
||||
PR_IMPLEMENT(char *)
|
||||
PL_strncasestr(const char *big, const char *little, PRUint32 max)
|
||||
{
|
||||
PRUint32 ll;
|
||||
|
||||
if( ((const char *)0 == big) || ((const char *)0 == little) ) return (char *)0;
|
||||
if( ((char)0 == *big) || ((char)0 == *little) ) return (char *)0;
|
||||
|
||||
ll = strlen(little);
|
||||
if( ll > max ) return (char *)0;
|
||||
max -= ll;
|
||||
max++;
|
||||
|
||||
for( ; max && *big; big++, max-- )
|
||||
/* obvious improvement available here */
|
||||
if( 0 == PL_strncasecmp(big, little, ll) )
|
||||
return (char *)big;
|
||||
|
||||
return (char *)0;
|
||||
}
|
||||
|
||||
PR_IMPLEMENT(char *)
|
||||
PL_strncaserstr(const char *big, const char *little, PRUint32 max)
|
||||
{
|
||||
const char *p;
|
||||
PRUint32 ll;
|
||||
|
||||
if( ((const char *)0 == big) || ((const char *)0 == little) ) return (char *)0;
|
||||
if( ((char)0 == *big) || ((char)0 == *little) ) return (char *)0;
|
||||
|
||||
ll = strlen(little);
|
||||
|
||||
for( p = big; max && *p; p++, max-- )
|
||||
;
|
||||
|
||||
p -= ll;
|
||||
if( p < big ) return (char *)0;
|
||||
|
||||
for( ; p >= big; p-- )
|
||||
/* obvious improvement available here */
|
||||
if( 0 == PL_strncasecmp(p, little, ll) )
|
||||
return (char *)p;
|
||||
|
||||
return (char *)0;
|
||||
}
|
||||
49
nsprpub/lib/libc/src/strcat.c
Normal file
49
nsprpub/lib/libc/src/strcat.c
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "plstr.h"
|
||||
#include <string.h>
|
||||
|
||||
PR_IMPLEMENT(char *)
|
||||
PL_strcat(char *dest, const char *src)
|
||||
{
|
||||
if( ((char *)0 == dest) || ((const char *)0 == src) )
|
||||
return dest;
|
||||
|
||||
return strcat(dest, src);
|
||||
}
|
||||
|
||||
PR_IMPLEMENT(char *)
|
||||
PL_strncat(char *dest, const char *src, PRUint32 max)
|
||||
{
|
||||
char *rv;
|
||||
|
||||
if( ((char *)0 == dest) || ((const char *)0 == src) || (0 == max) )
|
||||
return dest;
|
||||
|
||||
for( rv = dest; *dest; dest++ )
|
||||
;
|
||||
|
||||
(void)PL_strncpy(dest, src, max);
|
||||
return rv;
|
||||
}
|
||||
|
||||
PR_IMPLEMENT(char *)
|
||||
PL_strcatn(char *dest, PRUint32 max, const char *src)
|
||||
{
|
||||
char *rv;
|
||||
PRUint32 dl;
|
||||
|
||||
if( ((char *)0 == dest) || ((const char *)0 == src) )
|
||||
return dest;
|
||||
|
||||
for( rv = dest, dl = 0; *dest; dest++, dl++ )
|
||||
;
|
||||
|
||||
if( max <= dl ) return rv;
|
||||
(void)PL_strncpyz(dest, src, max-dl);
|
||||
|
||||
return rv;
|
||||
}
|
||||
56
nsprpub/lib/libc/src/strchr.c
Normal file
56
nsprpub/lib/libc/src/strchr.c
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "plstr.h"
|
||||
#include <string.h>
|
||||
|
||||
PR_IMPLEMENT(char *)
|
||||
PL_strchr(const char *s, char c)
|
||||
{
|
||||
if( (const char *)0 == s ) return (char *)0;
|
||||
|
||||
return strchr(s, c);
|
||||
}
|
||||
|
||||
PR_IMPLEMENT(char *)
|
||||
PL_strrchr(const char *s, char c)
|
||||
{
|
||||
if( (const char *)0 == s ) return (char *)0;
|
||||
|
||||
return strrchr(s, c);
|
||||
}
|
||||
|
||||
PR_IMPLEMENT(char *)
|
||||
PL_strnchr(const char *s, char c, PRUint32 n)
|
||||
{
|
||||
if( (const char *)0 == s ) return (char *)0;
|
||||
|
||||
for( ; n && *s; s++, n-- )
|
||||
if( *s == c )
|
||||
return (char *)s;
|
||||
|
||||
if( ((char)0 == c) && (n > 0) && ((char)0 == *s) ) return (char *)s;
|
||||
|
||||
return (char *)0;
|
||||
}
|
||||
|
||||
PR_IMPLEMENT(char *)
|
||||
PL_strnrchr(const char *s, char c, PRUint32 n)
|
||||
{
|
||||
const char *p;
|
||||
|
||||
if( (const char *)0 == s ) return (char *)0;
|
||||
|
||||
for( p = s; n && *p; p++, n-- )
|
||||
;
|
||||
|
||||
if( ((char)0 == c) && (n > 0) && ((char)0 == *p) ) return (char *)p;
|
||||
|
||||
for( p--; p >= s; p-- )
|
||||
if( *p == c )
|
||||
return (char *)p;
|
||||
|
||||
return (char *)0;
|
||||
}
|
||||
29
nsprpub/lib/libc/src/strcmp.c
Normal file
29
nsprpub/lib/libc/src/strcmp.c
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "plstr.h"
|
||||
#include <string.h>
|
||||
|
||||
PR_IMPLEMENT(PRIntn)
|
||||
PL_strcmp(const char *a, const char *b)
|
||||
{
|
||||
if( (const char *)0 == a )
|
||||
return ((const char *)0 == b) ? 0 : -1;
|
||||
if( (const char *)0 == b )
|
||||
return 1;
|
||||
|
||||
return (PRIntn)strcmp(a, b);
|
||||
}
|
||||
|
||||
PR_IMPLEMENT(PRIntn)
|
||||
PL_strncmp(const char *a, const char *b, PRUint32 max)
|
||||
{
|
||||
if( (const char *)0 == a )
|
||||
return ((const char *)0 == b) ? 0 : -1;
|
||||
if( (const char *)0 == b )
|
||||
return 1;
|
||||
|
||||
return (PRIntn)strncmp(a, b, (size_t)max);
|
||||
}
|
||||
52
nsprpub/lib/libc/src/strcpy.c
Normal file
52
nsprpub/lib/libc/src/strcpy.c
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "plstr.h"
|
||||
#include <string.h>
|
||||
|
||||
PR_IMPLEMENT(char *)
|
||||
PL_strcpy(char *dest, const char *src)
|
||||
{
|
||||
if( ((char *)0 == dest) || ((const char *)0 == src) ) return (char *)0;
|
||||
|
||||
return strcpy(dest, src);
|
||||
}
|
||||
|
||||
PR_IMPLEMENT(char *)
|
||||
PL_strncpy(char *dest, const char *src, PRUint32 max)
|
||||
{
|
||||
char *rv;
|
||||
|
||||
if( (char *)0 == dest ) return (char *)0;
|
||||
if( (const char *)0 == src ) return (char *)0;
|
||||
|
||||
for( rv = dest; max && ((*dest = *src) != 0); dest++, src++, max-- )
|
||||
;
|
||||
|
||||
#ifdef JLRU
|
||||
/* XXX I (wtc) think the -- and ++ operators should be postfix. */
|
||||
while( --max )
|
||||
*++dest = '\0';
|
||||
#endif /* JLRU */
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
PR_IMPLEMENT(char *)
|
||||
PL_strncpyz(char *dest, const char *src, PRUint32 max)
|
||||
{
|
||||
char *rv;
|
||||
|
||||
if( (char *)0 == dest ) return (char *)0;
|
||||
if( (const char *)0 == src ) return (char *)0;
|
||||
if( 0 == max ) return (char *)0;
|
||||
|
||||
for( rv = dest, max--; max && ((*dest = *src) != 0); dest++, src++, max-- )
|
||||
;
|
||||
|
||||
*dest = '\0';
|
||||
|
||||
return rv;
|
||||
}
|
||||
53
nsprpub/lib/libc/src/strdup.c
Normal file
53
nsprpub/lib/libc/src/strdup.c
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "plstr.h"
|
||||
#include "prmem.h"
|
||||
#include <string.h>
|
||||
|
||||
PR_IMPLEMENT(char *)
|
||||
PL_strdup(const char *s)
|
||||
{
|
||||
char *rv;
|
||||
size_t n;
|
||||
|
||||
if( (const char *)0 == s )
|
||||
s = "";
|
||||
|
||||
n = strlen(s) + 1;
|
||||
|
||||
rv = (char *)malloc(n);
|
||||
if( (char *)0 == rv ) return rv;
|
||||
|
||||
(void)memcpy(rv, s, n);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
PR_IMPLEMENT(void)
|
||||
PL_strfree(char *s)
|
||||
{
|
||||
free(s);
|
||||
}
|
||||
|
||||
PR_IMPLEMENT(char *)
|
||||
PL_strndup(const char *s, PRUint32 max)
|
||||
{
|
||||
char *rv;
|
||||
size_t l;
|
||||
|
||||
if( (const char *)0 == s )
|
||||
s = "";
|
||||
|
||||
l = PL_strnlen(s, max);
|
||||
|
||||
rv = (char *)malloc(l+1);
|
||||
if( (char *)0 == rv ) return rv;
|
||||
|
||||
(void)memcpy(rv, s, l);
|
||||
rv[l] = '\0';
|
||||
|
||||
return rv;
|
||||
}
|
||||
42
nsprpub/lib/libc/src/strlen.c
Normal file
42
nsprpub/lib/libc/src/strlen.c
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "plstr.h"
|
||||
#include "prtypes.h"
|
||||
#include "prlog.h"
|
||||
#include <string.h>
|
||||
|
||||
PR_IMPLEMENT(PRUint32)
|
||||
PL_strlen(const char *str)
|
||||
{
|
||||
size_t l;
|
||||
|
||||
if( (const char *)0 == str ) return 0;
|
||||
|
||||
l = strlen(str);
|
||||
|
||||
/* error checking in case we have a 64-bit platform -- make sure
|
||||
* we don't have ultra long strings that overflow an int32
|
||||
*/
|
||||
if( sizeof(PRUint32) < sizeof(size_t) )
|
||||
{
|
||||
if( l > PR_INT32_MAX )
|
||||
PR_Assert("l <= PR_INT32_MAX", __FILE__, __LINE__);
|
||||
}
|
||||
|
||||
return (PRUint32)l;
|
||||
}
|
||||
|
||||
PR_IMPLEMENT(PRUint32)
|
||||
PL_strnlen(const char *str, PRUint32 max)
|
||||
{
|
||||
register const char *s;
|
||||
|
||||
if( (const char *)0 == str ) return 0;
|
||||
for( s = str; max && *s; s++, max-- )
|
||||
;
|
||||
|
||||
return (PRUint32)(s - str);
|
||||
}
|
||||
68
nsprpub/lib/libc/src/strpbrk.c
Normal file
68
nsprpub/lib/libc/src/strpbrk.c
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "plstr.h"
|
||||
#include <string.h>
|
||||
|
||||
PR_IMPLEMENT(char *)
|
||||
PL_strpbrk(const char *s, const char *list)
|
||||
{
|
||||
if( ((const char *)0 == s) || ((const char *)0 == list) ) return (char *)0;
|
||||
|
||||
return strpbrk(s, list);
|
||||
}
|
||||
|
||||
PR_IMPLEMENT(char *)
|
||||
PL_strprbrk(const char *s, const char *list)
|
||||
{
|
||||
const char *p;
|
||||
const char *r;
|
||||
|
||||
if( ((const char *)0 == s) || ((const char *)0 == list) ) return (char *)0;
|
||||
|
||||
for( r = s; *r; r++ )
|
||||
;
|
||||
|
||||
for( r--; r >= s; r-- )
|
||||
for( p = list; *p; p++ )
|
||||
if( *r == *p )
|
||||
return (char *)r;
|
||||
|
||||
return (char *)0;
|
||||
}
|
||||
|
||||
PR_IMPLEMENT(char *)
|
||||
PL_strnpbrk(const char *s, const char *list, PRUint32 max)
|
||||
{
|
||||
const char *p;
|
||||
|
||||
if( ((const char *)0 == s) || ((const char *)0 == list) ) return (char *)0;
|
||||
|
||||
for( ; max && *s; s++, max-- )
|
||||
for( p = list; *p; p++ )
|
||||
if( *s == *p )
|
||||
return (char *)s;
|
||||
|
||||
return (char *)0;
|
||||
}
|
||||
|
||||
PR_IMPLEMENT(char *)
|
||||
PL_strnprbrk(const char *s, const char *list, PRUint32 max)
|
||||
{
|
||||
const char *p;
|
||||
const char *r;
|
||||
|
||||
if( ((const char *)0 == s) || ((const char *)0 == list) ) return (char *)0;
|
||||
|
||||
for( r = s; max && *r; r++, max-- )
|
||||
;
|
||||
|
||||
for( r--; r >= s; r-- )
|
||||
for( p = list; *p; p++ )
|
||||
if( *r == *p )
|
||||
return (char *)r;
|
||||
|
||||
return (char *)0;
|
||||
}
|
||||
85
nsprpub/lib/libc/src/strstr.c
Normal file
85
nsprpub/lib/libc/src/strstr.c
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "plstr.h"
|
||||
#include <string.h>
|
||||
|
||||
PR_IMPLEMENT(char *)
|
||||
PL_strstr(const char *big, const char *little)
|
||||
{
|
||||
if( ((const char *)0 == big) || ((const char *)0 == little) ) return (char *)0;
|
||||
if( ((char)0 == *big) || ((char)0 == *little) ) return (char *)0;
|
||||
|
||||
return strstr(big, little);
|
||||
}
|
||||
|
||||
PR_IMPLEMENT(char *)
|
||||
PL_strrstr(const char *big, const char *little)
|
||||
{
|
||||
const char *p;
|
||||
size_t ll;
|
||||
size_t bl;
|
||||
|
||||
if( ((const char *)0 == big) || ((const char *)0 == little) ) return (char *)0;
|
||||
if( ((char)0 == *big) || ((char)0 == *little) ) return (char *)0;
|
||||
|
||||
ll = strlen(little);
|
||||
bl = strlen(big);
|
||||
if( bl < ll ) return (char *)0;
|
||||
p = &big[ bl - ll ];
|
||||
|
||||
for( ; p >= big; p-- )
|
||||
if( *little == *p )
|
||||
if( 0 == strncmp(p, little, ll) )
|
||||
return (char *)p;
|
||||
|
||||
return (char *)0;
|
||||
}
|
||||
|
||||
PR_IMPLEMENT(char *)
|
||||
PL_strnstr(const char *big, const char *little, PRUint32 max)
|
||||
{
|
||||
size_t ll;
|
||||
|
||||
if( ((const char *)0 == big) || ((const char *)0 == little) ) return (char *)0;
|
||||
if( ((char)0 == *big) || ((char)0 == *little) ) return (char *)0;
|
||||
|
||||
ll = strlen(little);
|
||||
if( ll > (size_t)max ) return (char *)0;
|
||||
max -= (PRUint32)ll;
|
||||
max++;
|
||||
|
||||
for( ; max && *big; big++, max-- )
|
||||
if( *little == *big )
|
||||
if( 0 == strncmp(big, little, ll) )
|
||||
return (char *)big;
|
||||
|
||||
return (char *)0;
|
||||
}
|
||||
|
||||
PR_IMPLEMENT(char *)
|
||||
PL_strnrstr(const char *big, const char *little, PRUint32 max)
|
||||
{
|
||||
const char *p;
|
||||
size_t ll;
|
||||
|
||||
if( ((const char *)0 == big) || ((const char *)0 == little) ) return (char *)0;
|
||||
if( ((char)0 == *big) || ((char)0 == *little) ) return (char *)0;
|
||||
|
||||
ll = strlen(little);
|
||||
|
||||
for( p = big; max && *p; p++, max-- )
|
||||
;
|
||||
|
||||
p -= ll;
|
||||
if( p < big ) return (char *)0;
|
||||
|
||||
for( ; p >= big; p-- )
|
||||
if( *little == *p )
|
||||
if( 0 == strncmp(p, little, ll) )
|
||||
return (char *)p;
|
||||
|
||||
return (char *)0;
|
||||
}
|
||||
56
nsprpub/lib/libc/src/strtok.c
Normal file
56
nsprpub/lib/libc/src/strtok.c
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "plstr.h"
|
||||
|
||||
PR_IMPLEMENT(char *)
|
||||
PL_strtok_r(char *s1, const char *s2, char **lasts)
|
||||
{
|
||||
const char *sepp;
|
||||
int c, sc;
|
||||
char *tok;
|
||||
|
||||
if( s1 == NULL )
|
||||
{
|
||||
if( *lasts == NULL )
|
||||
return NULL;
|
||||
|
||||
s1 = *lasts;
|
||||
}
|
||||
|
||||
for( ; (c = *s1) != 0; s1++ )
|
||||
{
|
||||
for( sepp = s2 ; (sc = *sepp) != 0 ; sepp++ )
|
||||
{
|
||||
if( c == sc )
|
||||
break;
|
||||
}
|
||||
if( sc == 0 )
|
||||
break;
|
||||
}
|
||||
|
||||
if( c == 0 )
|
||||
{
|
||||
*lasts = NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
tok = s1++;
|
||||
|
||||
for( ; (c = *s1) != 0; s1++ )
|
||||
{
|
||||
for( sepp = s2; (sc = *sepp) != 0; sepp++ )
|
||||
{
|
||||
if( c == sc )
|
||||
{
|
||||
*s1++ = '\0';
|
||||
*lasts = s1;
|
||||
return tok;
|
||||
}
|
||||
}
|
||||
}
|
||||
*lasts = NULL;
|
||||
return tok;
|
||||
}
|
||||
1
nsprpub/lib/prstreams/.cvsignore
Normal file
1
nsprpub/lib/prstreams/.cvsignore
Normal file
|
|
@ -0,0 +1 @@
|
|||
Makefile
|
||||
148
nsprpub/lib/prstreams/Makefile.in
Normal file
148
nsprpub/lib/prstreams/Makefile.in
Normal file
|
|
@ -0,0 +1,148 @@
|
|||
#
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
#! gmake
|
||||
|
||||
MOD_DEPTH = ../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(MOD_DEPTH)/config/autoconf.mk
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
ifeq ($(OS_ARCH), IRIX)
|
||||
ifneq ($(OS_RELEASE),5.3)
|
||||
CCC_ONLY_FLAGS += -exceptions
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(OS_ARCH), BeOS)
|
||||
CFLAGS += -frtti -fexceptions
|
||||
endif
|
||||
|
||||
INCLUDES = -I$(dist_includedir)
|
||||
|
||||
HEADERS = $(wildcard $(srcdir)/*.h)
|
||||
|
||||
CSRCS = \
|
||||
plvrsion.c \
|
||||
$(NULL)
|
||||
|
||||
CXXSRCS = \
|
||||
prstrms.cpp \
|
||||
$(NULL)
|
||||
|
||||
OBJS = $(addprefix $(OBJDIR)/,$(CSRCS:.c=.$(OBJ_SUFFIX)) $(CXXSRCS:.cpp=.$(OBJ_SUFFIX)))
|
||||
|
||||
ifeq ($(OS_ARCH), WINNT)
|
||||
RES=$(OBJDIR)/prstrms.res
|
||||
RESNAME=prstrms.rc
|
||||
OS_LIBS = user32.lib
|
||||
else
|
||||
ifeq ($(OS_ARCH),OS2)
|
||||
OS_LIBS = -lstdcpp
|
||||
else
|
||||
ifeq ($(OS_ARCH), AIX)
|
||||
ifeq ($(OS_RELEASE), 4.1)
|
||||
ifeq ($(CLASSIC_NSPR),1)
|
||||
OS_LIBS += -lC -lc
|
||||
else
|
||||
OS_LIBS += -lC_r -lc_r
|
||||
endif
|
||||
else
|
||||
# makeC++SharedLib(_r) is in either /usr/lpp/xlC/bin
|
||||
# or /usr/ibmcxx/bin.
|
||||
ifeq ($(CLASSIC_NSPR),1)
|
||||
MKSHLIB = makeC++SharedLib -p 0
|
||||
else
|
||||
MKSHLIB = makeC++SharedLib_r -p 0
|
||||
endif
|
||||
OS_LIBS += -ldl
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(OS_ARCH),BeOS)
|
||||
OS_LIBS = -lstdc++.r4
|
||||
endif
|
||||
|
||||
ifeq ($(OS_ARCH), UNIXWARE)
|
||||
OS_LIBS += -lC
|
||||
endif
|
||||
|
||||
EXTRA_LIBS = $(LIBNSPR)
|
||||
|
||||
# On SCOOS, we can't link with extra libraries when
|
||||
# we build a shared library. If we do so, the linker doesn't
|
||||
# complain, but we would run into weird problems at run-time.
|
||||
# Therefore on these platforms, we link just the object files.
|
||||
ifeq ($(OS_ARCH),SCOOS)
|
||||
EXTRA_LIBS =
|
||||
endif
|
||||
|
||||
ifdef RESOLVE_LINK_SYMBOLS
|
||||
EXTRA_LIBS += $(OS_LIBS)
|
||||
endif
|
||||
|
||||
LIBRARY_NAME = prstrms
|
||||
LIBRARY_VERSION = $(MOD_MAJOR_VERSION)
|
||||
|
||||
RELEASE_HEADERS = $(HEADERS)
|
||||
RELEASE_HEADERS_DEST = $(RELEASE_INCLUDE_DIR)
|
||||
RELEASE_LIBS = $(TARGETS)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
#
|
||||
# Version information generation (begin)
|
||||
#
|
||||
ECHO = echo
|
||||
TINC = $(OBJDIR)/_pl_bld.h
|
||||
PROD = $(notdir $(SHARED_LIBRARY))
|
||||
NOW = $(MOD_DEPTH)/config/$(OBJDIR)/now
|
||||
SH_DATE = $(shell date "+%Y-%m-%d %T")
|
||||
SH_NOW = $(shell $(NOW))
|
||||
|
||||
ifeq ($(OS_ARCH), WINNT)
|
||||
SUF = i64
|
||||
else
|
||||
SUF = LL
|
||||
endif
|
||||
|
||||
$(TINC):
|
||||
@$(MAKE_OBJDIR)
|
||||
@$(ECHO) '#define _BUILD_STRING "$(SH_DATE)"' > $(TINC)
|
||||
@if test ! -z "$(SH_NOW)"; then \
|
||||
$(ECHO) '#define _BUILD_TIME $(SH_NOW)$(SUF)' >> $(TINC); \
|
||||
else \
|
||||
true; \
|
||||
fi
|
||||
@$(ECHO) '#define _PRODUCTION "$(PROD)"' >> $(TINC)
|
||||
|
||||
|
||||
$(OBJDIR)/plvrsion.$(OBJ_SUFFIX): plvrsion.c $(TINC)
|
||||
ifeq ($(OS_ARCH), WINNT)
|
||||
$(CC) -o $@ -c $(CFLAGS) -I$(OBJDIR) $<
|
||||
else
|
||||
$(CC) -o $@ -c $(CFLAGS) -I$(OBJDIR) $<
|
||||
endif
|
||||
#
|
||||
# Version information generation (end)
|
||||
#
|
||||
|
||||
export:: $(TARGETS) $(HEADERS)
|
||||
$(INSTALL) -m 444 $(HEADERS) $(dist_includedir)
|
||||
$(INSTALL) -m 444 $(TARGETS) $(dist_libdir)
|
||||
ifeq ($(OS_ARCH),OS2)
|
||||
$(INSTALL) -m 444 $(TARGETS) $(dist_bindir)
|
||||
endif
|
||||
ifeq ($(OS_ARCH),HP-UX)
|
||||
ifdef SHARED_LIBRARY
|
||||
$(INSTALL) -m 755 $(SHARED_LIBRARY) $(dist_libdir)
|
||||
endif
|
||||
endif
|
||||
93
nsprpub/lib/prstreams/plvrsion.c
Normal file
93
nsprpub/lib/prstreams/plvrsion.c
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "prinit.h"
|
||||
#include "prvrsion.h"
|
||||
|
||||
/************************************************************************/
|
||||
/**************************IDENTITY AND VERSIONING***********************/
|
||||
/************************************************************************/
|
||||
#include "_pl_bld.h"
|
||||
#if !defined(_BUILD_TIME)
|
||||
#ifdef HAVE_LONG_LONG
|
||||
#define _BUILD_TIME 0
|
||||
#else
|
||||
#define _BUILD_TIME {0, 0}
|
||||
#endif
|
||||
#endif
|
||||
#if !defined(_BUILD_STRING)
|
||||
#define _BUILD_STRING ""
|
||||
#endif
|
||||
#if !defined(_PRODUCTION)
|
||||
#define _PRODUCTION ""
|
||||
#endif
|
||||
#if defined(DEBUG)
|
||||
#define _DEBUG_STRING " (debug)"
|
||||
#else
|
||||
#define _DEBUG_STRING ""
|
||||
#endif
|
||||
|
||||
/*
|
||||
* A trick to expand the PR_VMAJOR macro before concatenation.
|
||||
*/
|
||||
#define CONCAT(x, y) x ## y
|
||||
#define CONCAT2(x, y) CONCAT(x, y)
|
||||
#define VERSION_DESC_NAME CONCAT2(prVersionDescription_libprstrms, PR_VMAJOR)
|
||||
|
||||
PRVersionDescription VERSION_DESC_NAME =
|
||||
{
|
||||
/* version */ 2, /* this is the only one supported */
|
||||
/* buildTime */ _BUILD_TIME, /* usecs since midnight 1/1/1970 GMT */
|
||||
/* buildTimeString */ _BUILD_STRING, /* ditto, but human readable */
|
||||
/* vMajor */ PR_VMAJOR, /* NSPR's version number */
|
||||
/* vMinor */ PR_VMINOR, /* and minor version */
|
||||
/* vPatch */ PR_VPATCH, /* and patch */
|
||||
/* beta */ PR_BETA, /* beta build boolean */
|
||||
#if defined(DEBUG)
|
||||
/* debug */ PR_TRUE, /* a debug build */
|
||||
#else
|
||||
/* debug */ PR_FALSE, /* an optomized build */
|
||||
#endif
|
||||
/* special */ PR_FALSE, /* they're all special, but ... */
|
||||
/* filename */ _PRODUCTION, /* the produced library name */
|
||||
/* description */ "Portable runtime", /* what we are */
|
||||
/* security */ "N/A", /* not applicable here */
|
||||
/* copywrite */ "Copyright (c) 1998 Netscape Communications Corporation. All Rights Reserved",
|
||||
/* comment */ "http://www.mozilla.org/MPL/",
|
||||
/* specialString */ ""
|
||||
};
|
||||
|
||||
#ifdef XP_UNIX
|
||||
|
||||
/*
|
||||
* Version information for the 'ident' and 'what commands
|
||||
*
|
||||
* NOTE: the first component of the concatenated rcsid string
|
||||
* must not end in a '$' to prevent rcs keyword substitution.
|
||||
*/
|
||||
static char rcsid[] = "$Header: NSPR " PR_VERSION _DEBUG_STRING
|
||||
" " _BUILD_STRING " $";
|
||||
static char sccsid[] = "@(#)NSPR " PR_VERSION _DEBUG_STRING
|
||||
" " _BUILD_STRING;
|
||||
|
||||
#endif /* XP_UNIX */
|
||||
|
||||
PR_IMPLEMENT(const PRVersionDescription*) libVersionPoint()
|
||||
{
|
||||
#ifdef XP_UNIX
|
||||
/*
|
||||
* Add dummy references to rcsid and sccsid to prevent them
|
||||
* from being optimized away as unused variables.
|
||||
*/
|
||||
const char *dummy;
|
||||
|
||||
dummy = rcsid;
|
||||
dummy = sccsid;
|
||||
#endif
|
||||
return &VERSION_DESC_NAME;
|
||||
} /* versionEntryPointType */
|
||||
|
||||
/* plvrsion.c */
|
||||
|
||||
516
nsprpub/lib/prstreams/prstrms.cpp
Normal file
516
nsprpub/lib/prstreams/prstrms.cpp
Normal file
|
|
@ -0,0 +1,516 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
/*
|
||||
* Robin J. Maxwell 11-22-96
|
||||
* Fredrik Roubert <roubert@google.com> 2010-07-23
|
||||
* Matt Austern <austern@google.com> 2010-07-23
|
||||
*/
|
||||
|
||||
#include "prstrms.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <ios>
|
||||
#include <new>
|
||||
|
||||
using std::ios_base;
|
||||
using std::iostream;
|
||||
using std::istream;
|
||||
using std::nothrow;
|
||||
using std::ostream;
|
||||
using std::streambuf;
|
||||
using std::streamsize;
|
||||
|
||||
|
||||
PRfilebuf::PRfilebuf():
|
||||
_fd(NULL),
|
||||
_opened(false),
|
||||
_allocated(false),
|
||||
_unbuffered(false),
|
||||
_user_buf(false),
|
||||
_buf_base(NULL),
|
||||
_buf_end(NULL) { }
|
||||
|
||||
|
||||
PRfilebuf::PRfilebuf(PRFileDesc *fd):
|
||||
_fd(fd),
|
||||
_opened(false),
|
||||
_allocated(false),
|
||||
_unbuffered(false),
|
||||
_user_buf(false),
|
||||
_buf_base(NULL),
|
||||
_buf_end(NULL) { }
|
||||
|
||||
|
||||
PRfilebuf::PRfilebuf(PRFileDesc *fd, char_type *ptr, streamsize len):
|
||||
_fd(fd),
|
||||
_opened(false),
|
||||
_allocated(false),
|
||||
_unbuffered(false),
|
||||
_user_buf(false),
|
||||
_buf_base(NULL),
|
||||
_buf_end(NULL)
|
||||
{
|
||||
setbuf(ptr, len);
|
||||
}
|
||||
|
||||
|
||||
PRfilebuf::~PRfilebuf()
|
||||
{
|
||||
if (_opened) {
|
||||
close();
|
||||
} else {
|
||||
sync();
|
||||
}
|
||||
if (_allocated) {
|
||||
delete _buf_base;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
PRfilebuf *PRfilebuf::open(
|
||||
const char *name, ios_base::openmode flags, PRIntn mode)
|
||||
{
|
||||
if (_fd != NULL) {
|
||||
return NULL; // Error if already open.
|
||||
}
|
||||
|
||||
// Translate flags argument.
|
||||
PRIntn prflags = 0;
|
||||
bool ate = (flags & ios_base::ate) != 0;
|
||||
flags &= ~(ios_base::ate | ios_base::binary);
|
||||
|
||||
// TODO: The flag PR_CREATE_FILE should probably be used for the cases
|
||||
// (out), (out|app), (out|trunc) and (in|out|trunc) as the C++ standard
|
||||
// specifies that these cases should open files 'as if by using fopen with
|
||||
// "w"'. But adding that flag here will cause the unit test to leave files
|
||||
// behind after running (which might or might not be an error in the unit
|
||||
// test) so the matter needs further investigation before any changes are
|
||||
// made. The old prstreams implementation used the non-standard flag
|
||||
// ios::nocreate to control the use of PR_CREATE_FILE.
|
||||
|
||||
if (flags == (ios_base::out)) {
|
||||
prflags = PR_WRONLY | PR_TRUNCATE;
|
||||
} else if (flags == (ios_base::out | ios_base::app)) {
|
||||
prflags = PR_RDWR | PR_APPEND;
|
||||
} else if (flags == (ios_base::out | ios_base::trunc)) {
|
||||
prflags = PR_WRONLY | PR_TRUNCATE;
|
||||
} else if (flags == (ios_base::in)) {
|
||||
prflags = PR_RDONLY;
|
||||
} else if (flags == (ios_base::in | ios_base::out)) {
|
||||
prflags = PR_RDWR;
|
||||
} else if (flags == (ios_base::in | ios_base::out | ios_base::trunc)) {
|
||||
prflags = PR_RDWR | PR_TRUNCATE;
|
||||
} else {
|
||||
return NULL; // Unrecognized flag combination.
|
||||
}
|
||||
|
||||
if ((_fd = PR_Open(name, prflags, mode)) == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
_opened = true;
|
||||
|
||||
if (ate &&
|
||||
seekoff(0, ios_base::end, flags) == pos_type(traits_type::eof())) {
|
||||
close();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
PRfilebuf *PRfilebuf::attach(PRFileDesc *fd)
|
||||
{
|
||||
if (_fd != NULL) {
|
||||
return NULL; // Error if already open.
|
||||
}
|
||||
|
||||
_opened = false;
|
||||
_fd = fd;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
PRfilebuf *PRfilebuf::close()
|
||||
{
|
||||
if (_fd == NULL)
|
||||
return NULL;
|
||||
|
||||
int status = sync();
|
||||
|
||||
if (PR_Close(_fd) == PR_FAILURE ||
|
||||
traits_type::eq_int_type(status, traits_type::eof())) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
_fd = NULL;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
streambuf *PRfilebuf::setbuf(char_type *ptr, streamsize len)
|
||||
{
|
||||
if (is_open() && _buf_end) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!ptr || len <= 0) {
|
||||
_unbuffered = true;
|
||||
} else {
|
||||
setb(ptr, ptr + len, false);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
streambuf::pos_type PRfilebuf::seekoff(
|
||||
off_type offset, ios_base::seekdir dir, ios_base::openmode /*flags*/)
|
||||
{
|
||||
if (PR_GetDescType(_fd) != PR_DESC_FILE) {
|
||||
return traits_type::eof();
|
||||
}
|
||||
|
||||
PRSeekWhence whence;
|
||||
PRInt64 pos;
|
||||
|
||||
switch (dir) {
|
||||
case ios_base::beg: whence = PR_SEEK_SET; break;
|
||||
case ios_base::cur: whence = PR_SEEK_CUR; break;
|
||||
case ios_base::end: whence = PR_SEEK_END; break;
|
||||
default:
|
||||
return traits_type::eof(); // This should never happen.
|
||||
}
|
||||
|
||||
if (traits_type::eq_int_type(sync(), traits_type::eof())) {
|
||||
return traits_type::eof();
|
||||
}
|
||||
|
||||
if ((pos = PR_Seek64(_fd, offset, whence)) == -1) {
|
||||
return traits_type::eof();
|
||||
}
|
||||
|
||||
return pos;
|
||||
}
|
||||
|
||||
|
||||
int PRfilebuf::sync()
|
||||
{
|
||||
if (_fd == NULL) {
|
||||
return traits_type::eof();
|
||||
}
|
||||
|
||||
if (!_unbuffered) {
|
||||
// Sync write area.
|
||||
PRInt32 waiting;
|
||||
if ((waiting = pptr() - pbase()) != 0) {
|
||||
PRInt32 nout;
|
||||
if ((nout = PR_Write(_fd, pbase(), waiting)) != waiting) {
|
||||
if (nout > 0) {
|
||||
// Should set _pptr -= nout.
|
||||
pbump(-nout);
|
||||
memmove(pbase(), pbase() + nout, waiting - nout);
|
||||
}
|
||||
return traits_type::eof();
|
||||
}
|
||||
}
|
||||
setp(NULL, NULL); // Empty put area.
|
||||
|
||||
if (PR_GetDescType(_fd) == PR_DESC_FILE) {
|
||||
// Sockets can't seek; don't need this.
|
||||
PROffset64 avail;
|
||||
if ((avail = in_avail()) > 0) {
|
||||
if (PR_Seek64(_fd, -avail, PR_SEEK_CUR) != -1) {
|
||||
return traits_type::eof();
|
||||
}
|
||||
}
|
||||
}
|
||||
setg(NULL, NULL, NULL); // Empty get area.
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
streambuf::int_type PRfilebuf::underflow()
|
||||
{
|
||||
PRInt32 count;
|
||||
char_type byte;
|
||||
|
||||
if (gptr() != NULL && gptr() < egptr()) {
|
||||
return traits_type::to_int_type(*gptr());
|
||||
}
|
||||
|
||||
// Make sure there is a reserve area.
|
||||
if (!_unbuffered && _buf_base == NULL && !allocate()) {
|
||||
return traits_type::eof();
|
||||
}
|
||||
|
||||
// Sync before new buffer created below.
|
||||
if (traits_type::eq_int_type(sync(), traits_type::eof())) {
|
||||
return traits_type::eof();
|
||||
}
|
||||
|
||||
if (_unbuffered) {
|
||||
if (PR_Read(_fd, &byte, 1) <= 0) {
|
||||
return traits_type::eof();
|
||||
}
|
||||
|
||||
return traits_type::to_int_type(byte);
|
||||
}
|
||||
|
||||
if ((count = PR_Read(_fd, _buf_base, _buf_end - _buf_base)) <= 0) {
|
||||
return traits_type::eof(); // Reached EOF.
|
||||
}
|
||||
|
||||
setg(_buf_base, _buf_base, _buf_base + count);
|
||||
return traits_type::to_int_type(*gptr());
|
||||
}
|
||||
|
||||
|
||||
streambuf::int_type PRfilebuf::overflow(int_type c)
|
||||
{
|
||||
// Make sure there is a reserve area.
|
||||
if (!_unbuffered && _buf_base == NULL && !allocate()) {
|
||||
return traits_type::eof();
|
||||
}
|
||||
|
||||
// Sync before new buffer created below.
|
||||
if (traits_type::eq_int_type(sync(), traits_type::eof())) {
|
||||
return traits_type::eof();
|
||||
}
|
||||
|
||||
if (!_unbuffered) {
|
||||
setp(_buf_base, _buf_end);
|
||||
}
|
||||
|
||||
if (!traits_type::eq_int_type(c, traits_type::eof())) {
|
||||
// Extract the byte to be written.
|
||||
// (Required on big-endian architectures.)
|
||||
char_type byte = traits_type::to_char_type(c);
|
||||
if (!_unbuffered && pptr() < epptr()) { // Guard against recursion.
|
||||
return sputc(byte);
|
||||
} else {
|
||||
if (PR_Write(_fd, &byte, 1) != 1) {
|
||||
return traits_type::eof();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return traits_type::not_eof(c);
|
||||
}
|
||||
|
||||
|
||||
bool PRfilebuf::allocate()
|
||||
{
|
||||
char_type *buf = new(nothrow) char_type[BUFSIZ];
|
||||
if (buf == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
setb(buf, buf + BUFSIZ, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void PRfilebuf::setb(char_type *buf_base, char_type *buf_end, bool user_buf)
|
||||
{
|
||||
if (_buf_base && !_user_buf) {
|
||||
delete[] _buf_base;
|
||||
}
|
||||
|
||||
_buf_base = buf_base;
|
||||
_buf_end = buf_end;
|
||||
_user_buf = user_buf;
|
||||
}
|
||||
|
||||
|
||||
PRifstream::PRifstream():
|
||||
istream(NULL),
|
||||
_filebuf()
|
||||
{
|
||||
init(&_filebuf);
|
||||
}
|
||||
|
||||
|
||||
PRifstream::PRifstream(PRFileDesc *fd):
|
||||
istream(NULL),
|
||||
_filebuf(fd)
|
||||
{
|
||||
init(&_filebuf);
|
||||
}
|
||||
|
||||
|
||||
PRifstream::PRifstream(PRFileDesc *fd, char_type *ptr, streamsize len):
|
||||
istream(NULL),
|
||||
_filebuf(fd, ptr, len)
|
||||
{
|
||||
init(&_filebuf);
|
||||
}
|
||||
|
||||
|
||||
PRifstream::PRifstream(const char *name, openmode flags, PRIntn mode):
|
||||
istream(NULL),
|
||||
_filebuf()
|
||||
{
|
||||
init(&_filebuf);
|
||||
if (!_filebuf.open(name, flags | in, mode)) {
|
||||
setstate(failbit);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
PRifstream::~PRifstream() { }
|
||||
|
||||
|
||||
void PRifstream::open(const char *name, openmode flags, PRIntn mode)
|
||||
{
|
||||
if (is_open() || !_filebuf.open(name, flags | in, mode)) {
|
||||
setstate(failbit);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void PRifstream::attach(PRFileDesc *fd)
|
||||
{
|
||||
if (!_filebuf.attach(fd)) {
|
||||
setstate(failbit);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void PRifstream::close()
|
||||
{
|
||||
if (_filebuf.close() == NULL) {
|
||||
setstate(failbit);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
PRofstream::PRofstream():
|
||||
ostream(NULL),
|
||||
_filebuf()
|
||||
{
|
||||
init(&_filebuf);
|
||||
}
|
||||
|
||||
|
||||
PRofstream::PRofstream(PRFileDesc *fd):
|
||||
ostream(NULL),
|
||||
_filebuf(fd)
|
||||
{
|
||||
init(&_filebuf);
|
||||
}
|
||||
|
||||
|
||||
PRofstream::PRofstream(PRFileDesc *fd, char_type *ptr, streamsize len):
|
||||
ostream(NULL),
|
||||
_filebuf(fd, ptr, len)
|
||||
{
|
||||
init(&_filebuf);
|
||||
}
|
||||
|
||||
|
||||
PRofstream::PRofstream(const char *name, openmode flags, PRIntn mode):
|
||||
ostream(NULL),
|
||||
_filebuf()
|
||||
{
|
||||
init(&_filebuf);
|
||||
if (!_filebuf.open(name, flags | out, mode)) {
|
||||
setstate(failbit);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
PRofstream::~PRofstream() { }
|
||||
|
||||
|
||||
void PRofstream::open(const char *name, openmode flags, PRIntn mode)
|
||||
{
|
||||
if (is_open() || !_filebuf.open(name, flags | out, mode)) {
|
||||
setstate(failbit);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void PRofstream::attach(PRFileDesc *fd)
|
||||
{
|
||||
if (!_filebuf.attach(fd)) {
|
||||
setstate(failbit);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void PRofstream::close()
|
||||
{
|
||||
if (_filebuf.close() == NULL) {
|
||||
setstate(failbit);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
PRfstream::PRfstream():
|
||||
iostream(NULL),
|
||||
_filebuf()
|
||||
{
|
||||
init(&_filebuf);
|
||||
}
|
||||
|
||||
|
||||
PRfstream::PRfstream(PRFileDesc *fd):
|
||||
iostream(NULL),
|
||||
_filebuf(fd)
|
||||
{
|
||||
init(&_filebuf);
|
||||
}
|
||||
|
||||
|
||||
PRfstream::PRfstream(PRFileDesc *fd, char_type *ptr, streamsize len):
|
||||
iostream(NULL),
|
||||
_filebuf(fd, ptr, len)
|
||||
{
|
||||
init(&_filebuf);
|
||||
}
|
||||
|
||||
|
||||
PRfstream::PRfstream(const char *name, openmode flags, PRIntn mode):
|
||||
iostream(NULL),
|
||||
_filebuf()
|
||||
{
|
||||
init(&_filebuf);
|
||||
if (!_filebuf.open(name, flags | in | out, mode)) {
|
||||
setstate(failbit);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
PRfstream::~PRfstream() { }
|
||||
|
||||
|
||||
void PRfstream::open(const char *name, openmode flags, PRIntn mode)
|
||||
{
|
||||
if (is_open() || !_filebuf.open(name, flags | in | out, mode)) {
|
||||
setstate(failbit);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void PRfstream::attach(PRFileDesc *fd)
|
||||
{
|
||||
if (!_filebuf.attach(fd)) {
|
||||
setstate(failbit);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void PRfstream::close()
|
||||
{
|
||||
if (_filebuf.close() == NULL) {
|
||||
setstate(failbit);
|
||||
}
|
||||
}
|
||||
140
nsprpub/lib/prstreams/prstrms.h
Normal file
140
nsprpub/lib/prstreams/prstrms.h
Normal file
|
|
@ -0,0 +1,140 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
/*
|
||||
* Robin J. Maxwell 11-22-96
|
||||
* Fredrik Roubert <roubert@google.com> 2010-07-23
|
||||
* Matt Austern <austern@google.com> 2010-07-23
|
||||
*/
|
||||
|
||||
#ifndef _PRSTRMS_H
|
||||
#define _PRSTRMS_H
|
||||
|
||||
#include <cstddef>
|
||||
#include <istream>
|
||||
#include <ostream>
|
||||
#include <streambuf>
|
||||
|
||||
#include "prio.h"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
// http://support.microsoft.com/kb/q168958/
|
||||
class PR_IMPLEMENT(std::_Mutex);
|
||||
class PR_IMPLEMENT(std::ios_base);
|
||||
#endif
|
||||
|
||||
|
||||
class PR_IMPLEMENT(PRfilebuf): public std::streambuf
|
||||
{
|
||||
public:
|
||||
PRfilebuf();
|
||||
PRfilebuf(PRFileDesc *fd);
|
||||
PRfilebuf(PRFileDesc *fd, char_type *ptr, std::streamsize len);
|
||||
virtual ~PRfilebuf();
|
||||
|
||||
bool is_open() const { return _fd != NULL; }
|
||||
|
||||
PRfilebuf *open(
|
||||
const char *name,
|
||||
std::ios_base::openmode flags,
|
||||
PRIntn mode);
|
||||
PRfilebuf *attach(PRFileDesc *fd);
|
||||
PRfilebuf *close();
|
||||
|
||||
protected:
|
||||
virtual std::streambuf *setbuf(char_type *ptr, std::streamsize len);
|
||||
virtual pos_type seekoff(
|
||||
off_type offset,
|
||||
std::ios_base::seekdir dir,
|
||||
std::ios_base::openmode flags);
|
||||
virtual pos_type seekpos(
|
||||
pos_type pos,
|
||||
std::ios_base::openmode flags) {
|
||||
return seekoff(pos, std::ios_base::beg, flags);
|
||||
}
|
||||
virtual int sync();
|
||||
virtual int_type underflow();
|
||||
virtual int_type overflow(int_type c = traits_type::eof());
|
||||
|
||||
// TODO: Override pbackfail(), showmanyc(), uflow(), xsgetn(), and xsputn().
|
||||
|
||||
private:
|
||||
bool allocate();
|
||||
void setb(char_type *buf_base, char_type *buf_end, bool user_buf);
|
||||
|
||||
PRFileDesc *_fd;
|
||||
bool _opened;
|
||||
bool _allocated;
|
||||
bool _unbuffered;
|
||||
bool _user_buf;
|
||||
char_type *_buf_base;
|
||||
char_type *_buf_end;
|
||||
};
|
||||
|
||||
|
||||
class PR_IMPLEMENT(PRifstream): public std::istream
|
||||
{
|
||||
public:
|
||||
PRifstream();
|
||||
PRifstream(PRFileDesc *fd);
|
||||
PRifstream(PRFileDesc *fd, char_type *ptr, std::streamsize len);
|
||||
PRifstream(const char *name, openmode flags = in, PRIntn mode = 0);
|
||||
virtual ~PRifstream();
|
||||
|
||||
PRfilebuf *rdbuf() const { return &_filebuf; }
|
||||
bool is_open() const { return _filebuf.is_open(); }
|
||||
|
||||
void open(const char *name, openmode flags = in, PRIntn mode = 0);
|
||||
void attach(PRFileDesc *fd);
|
||||
void close();
|
||||
|
||||
private:
|
||||
mutable PRfilebuf _filebuf;
|
||||
};
|
||||
|
||||
|
||||
class PR_IMPLEMENT(PRofstream): public std::ostream
|
||||
{
|
||||
public:
|
||||
PRofstream();
|
||||
PRofstream(PRFileDesc *fd);
|
||||
PRofstream(PRFileDesc *fd, char_type *ptr, std::streamsize len);
|
||||
PRofstream(const char *name, openmode flags = out, PRIntn mode = 0);
|
||||
virtual ~PRofstream();
|
||||
|
||||
PRfilebuf *rdbuf() const { return &_filebuf; }
|
||||
bool is_open() const { return _filebuf.is_open(); }
|
||||
|
||||
void open(const char *name, openmode flags = out, PRIntn mode = 0);
|
||||
void attach(PRFileDesc *fd);
|
||||
void close();
|
||||
|
||||
private:
|
||||
mutable PRfilebuf _filebuf;
|
||||
};
|
||||
|
||||
|
||||
class PR_IMPLEMENT(PRfstream): public std::iostream
|
||||
{
|
||||
public:
|
||||
PRfstream();
|
||||
PRfstream(PRFileDesc *fd);
|
||||
PRfstream(PRFileDesc *fd, char_type *ptr, std::streamsize len);
|
||||
PRfstream(const char *name, openmode flags = in | out, PRIntn mode = 0);
|
||||
virtual ~PRfstream();
|
||||
|
||||
PRfilebuf *rdbuf() const { return &_filebuf; }
|
||||
bool is_open() const { return _filebuf.is_open(); }
|
||||
|
||||
void open(const char *name, openmode flags = in | out, PRIntn mode = 0);
|
||||
void attach(PRFileDesc *fd);
|
||||
void close();
|
||||
|
||||
private:
|
||||
mutable PRfilebuf _filebuf;
|
||||
};
|
||||
|
||||
|
||||
#endif /* _PRSTRMS_H */
|
||||
69
nsprpub/lib/prstreams/prstrms.rc
Normal file
69
nsprpub/lib/prstreams/prstrms.rc
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "prinit.h"
|
||||
#include <winver.h>
|
||||
|
||||
#define MY_LIBNAME "prstrms"
|
||||
#define MY_FILEDESCRIPTION "PRSTRMS Library"
|
||||
|
||||
#define STRINGIZE(x) #x
|
||||
#define STRINGIZE2(x) STRINGIZE(x)
|
||||
#define PR_VMAJOR_STR STRINGIZE2(PR_VMAJOR)
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define MY_DEBUG_STR " (debug)"
|
||||
#define MY_FILEFLAGS_1 VS_FF_DEBUG
|
||||
#else
|
||||
#define MY_DEBUG_STR ""
|
||||
#define MY_FILEFLAGS_1 0x0L
|
||||
#endif
|
||||
#if PR_BETA
|
||||
#define MY_FILEFLAGS_2 MY_FILEFLAGS_1|VS_FF_PRERELEASE
|
||||
#else
|
||||
#define MY_FILEFLAGS_2 MY_FILEFLAGS_1
|
||||
#endif
|
||||
|
||||
#ifdef WINNT
|
||||
#define MY_FILEOS VOS_NT_WINDOWS32
|
||||
#define MY_INTERNAL_NAME "lib" MY_LIBNAME PR_VMAJOR_STR
|
||||
#else
|
||||
#define MY_FILEOS VOS__WINDOWS32
|
||||
#define MY_INTERNAL_NAME MY_LIBNAME PR_VMAJOR_STR
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Version-information resource
|
||||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION PR_VMAJOR,PR_VMINOR,PR_VPATCH,0
|
||||
PRODUCTVERSION PR_VMAJOR,PR_VMINOR,PR_VPATCH,0
|
||||
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
|
||||
FILEFLAGS MY_FILEFLAGS_2
|
||||
FILEOS MY_FILEOS
|
||||
FILETYPE VFT_DLL
|
||||
FILESUBTYPE 0x0L // not used
|
||||
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040904B0" // Lang=US English, CharSet=Unicode
|
||||
BEGIN
|
||||
VALUE "CompanyName", "Mozilla Foundation\0"
|
||||
VALUE "FileDescription", MY_FILEDESCRIPTION MY_DEBUG_STR "\0"
|
||||
VALUE "FileVersion", PR_VERSION "\0"
|
||||
VALUE "InternalName", MY_INTERNAL_NAME "\0"
|
||||
VALUE "OriginalFilename", MY_INTERNAL_NAME ".dll\0"
|
||||
VALUE "ProductName", "Netscape Portable Runtime\0"
|
||||
VALUE "ProductVersion", PR_VERSION "\0"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x409, 1200
|
||||
END
|
||||
END
|
||||
1
nsprpub/lib/prstreams/tests/testprstrm/.cvsignore
Normal file
1
nsprpub/lib/prstreams/tests/testprstrm/.cvsignore
Normal file
|
|
@ -0,0 +1 @@
|
|||
Makefile
|
||||
168
nsprpub/lib/prstreams/tests/testprstrm/Makefile.in
Normal file
168
nsprpub/lib/prstreams/tests/testprstrm/Makefile.in
Normal file
|
|
@ -0,0 +1,168 @@
|
|||
#
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
#! gmake
|
||||
|
||||
MOD_DEPTH = ../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(MOD_DEPTH)/config/autoconf.mk
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
CXXSRCS = \
|
||||
testprstrm.cpp \
|
||||
$(NULL)
|
||||
|
||||
OBJS = $(addprefix $(OBJDIR)/,$(CXXSRCS:.cpp=.$(OBJ_SUFFIX)))
|
||||
|
||||
ifeq (,$(filter-out WINNT OS2,$(OS_ARCH)))
|
||||
PROG_SUFFIX = .exe
|
||||
else
|
||||
PROG_SUFFIX =
|
||||
endif
|
||||
|
||||
PROGS = $(addprefix $(OBJDIR)/, $(CXXSRCS:.cpp=$(PROG_SUFFIX)))
|
||||
|
||||
TARGETS = $(PROGS) $(OBJS)
|
||||
|
||||
INCLUDES = -I$(dist_includedir)
|
||||
|
||||
# Setting the variables LDOPTS and LIBPR. We first initialize
|
||||
# them to the default values, then adjust them for some platforms.
|
||||
LDOPTS = -L$(dist_libdir)
|
||||
LIBPR = -lnspr$(MOD_MAJOR_VERSION)
|
||||
LIBPRSTRMS = -lprstrms$(MOD_MAJOR_VERSION)
|
||||
|
||||
ifeq ($(OS_ARCH), WINNT)
|
||||
LDOPTS = -NOLOGO -DEBUG -INCREMENTAL:NO
|
||||
ifeq ($(OS_TARGET), WIN95)
|
||||
LIBPR = $(dist_libdir)/nspr$(MOD_MAJOR_VERSION).$(LIB_SUFFIX)
|
||||
LIBPRSTRMS = $(dist_libdir)/prstrms$(MOD_MAJOR_VERSION).$(LIB_SUFFIX)
|
||||
else
|
||||
LIBPR = $(dist_libdir)/libnspr$(MOD_MAJOR_VERSION).$(LIB_SUFFIX)
|
||||
LIBPRSTRMS = $(dist_libdir)/libprstrms$(MOD_MAJOR_VERSION).$(LIB_SUFFIX)
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(OS_ARCH),OS2)
|
||||
LDOPTS += -Zomf -Zlinker /PM:VIO -lstdcpp
|
||||
endif
|
||||
|
||||
ifneq ($(OS_ARCH), WINNT)
|
||||
PWD = $(shell pwd)
|
||||
endif
|
||||
|
||||
ifeq ($(OS_ARCH), IRIX)
|
||||
LDOPTS += -rpath $(PWD)/$(dist_libdir)
|
||||
endif
|
||||
|
||||
ifeq ($(OS_ARCH), OSF1)
|
||||
LDOPTS += -rpath $(PWD)/$(dist_libdir)
|
||||
endif
|
||||
|
||||
ifeq ($(OS_ARCH), HP-UX)
|
||||
LDOPTS += -Wl,+s,+b,$(PWD)/$(dist_libdir)
|
||||
endif
|
||||
|
||||
# AIX
|
||||
ifeq ($(OS_ARCH),AIX)
|
||||
LDOPTS += -blibpath:$(PWD)/$(dist_libdir):/usr/lib:/lib
|
||||
ifeq ($(OS_ARCH)$(OS_RELEASE),AIX4.1)
|
||||
LIBPR = -lnspr$(MOD_MAJOR_VERSION)_shr
|
||||
LIBPRSTRMS = -lprstrms$(MOD_MAJOR_VERSION)_shr
|
||||
else
|
||||
LDOPTS += -brtl
|
||||
EXTRA_LIBS = -ldl
|
||||
endif
|
||||
endif
|
||||
|
||||
# Solaris
|
||||
ifeq ($(OS_ARCH), SunOS)
|
||||
ifdef NS_USE_GCC
|
||||
LDOPTS += -Xlinker -R -Xlinker $(PWD)/$(dist_libdir)
|
||||
else
|
||||
LDOPTS += -R $(PWD)/$(dist_libdir)
|
||||
# CC on SunOS 5.5.x needs to link with -lpthread even though we already
|
||||
# linked with this system library when we built libnspr.so.
|
||||
ifdef USE_PTHREADS
|
||||
EXTRA_LIBS = -lpthread
|
||||
endif # USE_PTHREADS
|
||||
endif # NS_USE_GCC
|
||||
endif # SunOS
|
||||
|
||||
ifeq ($(OS_ARCH), SCOOS)
|
||||
# SCO Unix needs to link against -lsocket again even though we
|
||||
# already linked with these system libraries when we built libnspr.so.
|
||||
EXTRA_LIBS = -lsocket
|
||||
# This hardcodes in the executable programs the directory to find
|
||||
# libnspr.so etc. at program startup. Equivalent to the -R or -rpath
|
||||
# option for ld on other platforms.
|
||||
export LD_RUN_PATH = $(PWD)/$(dist_libdir)
|
||||
endif
|
||||
|
||||
ifeq ($(OS_ARCH), UNIXWARE)
|
||||
export LD_RUN_PATH = $(PWD)/$(dist_libdir)
|
||||
endif
|
||||
|
||||
#####################################################
|
||||
#
|
||||
# The rules
|
||||
#
|
||||
#####################################################
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
AIX_PRE_4_2 = 0
|
||||
ifeq ($(OS_ARCH),AIX)
|
||||
ifneq ($(OS_RELEASE),4.2)
|
||||
ifneq ($(USE_PTHREADS), 1)
|
||||
#AIX_PRE_4_2 = 1
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(AIX_PRE_4_2),1)
|
||||
|
||||
# AIX releases prior to 4.2 need a special two-step linking hack
|
||||
# in order to both override the system select() and be able to
|
||||
# get at the original system select().
|
||||
#
|
||||
# We use a pattern rule in ns/nspr20/config/rules.mk to generate
|
||||
# the .$(OBJ_SUFFIX) file from the .c source file, then do the
|
||||
# two-step linking hack below.
|
||||
|
||||
$(OBJDIR)/%: $(OBJDIR)/%.$(OBJ_SUFFIX)
|
||||
@$(MAKE_OBJDIR)
|
||||
rm -f $@ $(AIX_TMP)
|
||||
$(CC) $(AIX_LINK_OPTS) -o $(AIX_TMP) $< $(dist_libdir)/libnspr$(MOD_MAJOR_VERSION).a
|
||||
$(CC) -o $@ $(AIX_TMP) $(AIX_WRAP)
|
||||
rm -f $(AIX_TMP)
|
||||
|
||||
else
|
||||
|
||||
# All platforms that are not AIX pre-4.2.
|
||||
|
||||
$(OBJDIR)/%$(PROG_SUFFIX): $(OBJDIR)/%.$(OBJ_SUFFIX)
|
||||
@$(MAKE_OBJDIR)
|
||||
ifeq ($(OS_ARCH), WINNT)
|
||||
link $(LDOPTS) $< $(LIBPR) $(LIBPRSTRMS) ws2_32.lib -out:$@
|
||||
else
|
||||
ifeq ($(OS_ARCH),OS2)
|
||||
$(LINK) $(EXEFLAGS) $(LDOPTS) $< $(LIBPR) $(LIBPRSTRMS) $(OS_LIBS) $(EXTRA_LIBS)
|
||||
else
|
||||
$(CCC) $(XCFLAGS) $< $(LDOPTS) $(LIBPR) $(LIBPRSTRMS) $(EXTRA_LIBS) -o $@
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
export:: $(TARGETS)
|
||||
clean::
|
||||
rm -f $(TARGETS)
|
||||
|
||||
testlinker:
|
||||
echo $(LINK)
|
||||
171
nsprpub/lib/prstreams/tests/testprstrm/testprstrm.cpp
Normal file
171
nsprpub/lib/prstreams/tests/testprstrm/testprstrm.cpp
Normal file
|
|
@ -0,0 +1,171 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "prstrms.h"
|
||||
|
||||
#include "prinit.h"
|
||||
#include "prio.h"
|
||||
#include "prthread.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
|
||||
#ifdef XP_UNIX
|
||||
#include <sys/stat.h>
|
||||
#endif
|
||||
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
using std::ios;
|
||||
|
||||
const unsigned int MaxCnt = 1;
|
||||
|
||||
typedef struct threadarg {
|
||||
const char *mytag;
|
||||
} threadarg;
|
||||
|
||||
void threadwork(threadarg *arg);
|
||||
|
||||
void
|
||||
threadmain(void *mytag)
|
||||
{
|
||||
threadarg arg;
|
||||
|
||||
arg.mytag = static_cast<const char *>(mytag);
|
||||
|
||||
threadwork(&arg);
|
||||
}
|
||||
|
||||
void
|
||||
threadwork(threadarg *arg)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
char fname1[256];
|
||||
char fname2[256];
|
||||
|
||||
strcpy(fname1, arg->mytag);
|
||||
strcpy(fname2, arg->mytag);
|
||||
strcat(fname2, "2");
|
||||
PR_Delete(fname1);
|
||||
PR_Delete(fname2);
|
||||
|
||||
PRfilebuf *fb[MaxCnt];
|
||||
PRifstream *ifs[MaxCnt];
|
||||
PRofstream *ofs[MaxCnt];
|
||||
int mode = 0;
|
||||
#ifdef XP_UNIX
|
||||
mode = S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH;
|
||||
#endif
|
||||
|
||||
//
|
||||
// Allocate a bunch
|
||||
cout << "Testing unused filebufs ----------------" << endl;
|
||||
for (i=0; i < MaxCnt; i++){
|
||||
fb[i] = new PRfilebuf;
|
||||
}
|
||||
// Delete them
|
||||
for (i=0; i < MaxCnt; i++){
|
||||
delete fb[i];
|
||||
}
|
||||
cout << "Unused filebufs complete ---------------" << endl;
|
||||
|
||||
//
|
||||
// Allocate a bunch
|
||||
cout << "Testing unused ifstream -----------------" << endl;
|
||||
for (i=0; i < MaxCnt; i++){
|
||||
ifs[i] = new PRifstream;
|
||||
}
|
||||
//
|
||||
// Delete them
|
||||
for (i=0; i < MaxCnt; i++){
|
||||
delete ifs[i];
|
||||
}
|
||||
cout << "Unused ifstream complete ----------------" << endl;
|
||||
//
|
||||
// Allocate a bunch
|
||||
cout << "Testing unused ofstream -----------------" << endl;
|
||||
for (i=0; i < MaxCnt; i++){
|
||||
ofs[i] = new PRofstream;
|
||||
}
|
||||
for (i=0; i < MaxCnt; i++){
|
||||
*(ofs[i]) << "A"; // Write a bit
|
||||
delete ofs[i]; // Delete it.
|
||||
}
|
||||
cout << "Unused ofstream complete ----------------" << endl;
|
||||
|
||||
cout << "Testing use of ofstream 1 (extra filebuf allocated) ---------" << endl;
|
||||
PRofstream *aos = new PRofstream(fname1, ios::out|ios::ate, mode);
|
||||
for (i=0; i < MaxCnt; i++){
|
||||
for (int j=0; j < 8192; j++)
|
||||
*aos << "AaBbCcDdEeFfGg" << endl;
|
||||
fb[i] = new PRfilebuf; // Allocate as we go to hack at the heap
|
||||
}
|
||||
//
|
||||
// Delete the extra foo we allocated
|
||||
for (i=0; i < MaxCnt; i++){
|
||||
delete fb[i];
|
||||
}
|
||||
aos->flush(); // Explicit flush
|
||||
delete aos;
|
||||
cout << "Testing use of ofstream 1 complete (extra filebuf deleted) --" << endl;
|
||||
cout << "Testing use of ofstream 2 (extra filebuf allocated) ---------" << endl;
|
||||
PRofstream *aos2 = new PRofstream(fname2, ios::out, mode);
|
||||
|
||||
for (i=0; i < MaxCnt; i++){
|
||||
*aos2 << "AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz";
|
||||
}
|
||||
// Force flushing in the dtor
|
||||
delete aos2;
|
||||
cout << "Testing use of ofstream 2 complete (extra filebuf deleted) --" << endl;
|
||||
char line[1024];
|
||||
cout << "Testing use of ifstream 1 (stack allocation) -------------" << endl;
|
||||
PRifstream ais(fname1);
|
||||
for (i=0; i < MaxCnt; i++){
|
||||
ais >> line;
|
||||
}
|
||||
cout << "Testing use of ifstream 1 complete -----------------------" << endl;
|
||||
cout << "Testing use of ifstream 2 ----------------------" << endl;
|
||||
PRifstream *ais2 = new PRifstream(fname2);
|
||||
char achar;
|
||||
for (i=0; i < MaxCnt*10; i++){
|
||||
*ais2 >> achar;
|
||||
}
|
||||
delete ais2;
|
||||
cout << "Testing use of ifstream 2 complete -------------" << endl;
|
||||
}
|
||||
|
||||
#define STACKSIZE 1024*1024
|
||||
int
|
||||
main()
|
||||
{
|
||||
PR_Init(PR_SYSTEM_THREAD, PR_PRIORITY_NORMAL, 256);
|
||||
threadmain(const_cast<char *>("TestFile"));
|
||||
PRThread *thr1 = PR_CreateThread(PR_SYSTEM_THREAD,
|
||||
threadmain,
|
||||
const_cast<char *>("TestFile1"),
|
||||
PR_PRIORITY_NORMAL,
|
||||
PR_GLOBAL_THREAD,
|
||||
PR_JOINABLE_THREAD,
|
||||
STACKSIZE);
|
||||
PRThread *thr2 = PR_CreateThread(PR_SYSTEM_THREAD,
|
||||
threadmain,
|
||||
const_cast<char *>("TestFile2"),
|
||||
PR_PRIORITY_NORMAL,
|
||||
PR_GLOBAL_THREAD,
|
||||
PR_JOINABLE_THREAD,
|
||||
STACKSIZE);
|
||||
PRThread *thr3 = PR_CreateThread(PR_SYSTEM_THREAD,
|
||||
threadmain,
|
||||
const_cast<char *>("TestFile3"),
|
||||
PR_PRIORITY_NORMAL,
|
||||
PR_GLOBAL_THREAD,
|
||||
PR_JOINABLE_THREAD,
|
||||
STACKSIZE);
|
||||
PR_JoinThread(thr1);
|
||||
PR_JoinThread(thr2);
|
||||
PR_JoinThread(thr3);
|
||||
return 0;
|
||||
}
|
||||
1
nsprpub/lib/tests/.cvsignore
Normal file
1
nsprpub/lib/tests/.cvsignore
Normal file
|
|
@ -0,0 +1 @@
|
|||
Makefile
|
||||
178
nsprpub/lib/tests/Makefile.in
Normal file
178
nsprpub/lib/tests/Makefile.in
Normal file
|
|
@ -0,0 +1,178 @@
|
|||
#
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
#! gmake
|
||||
|
||||
MOD_DEPTH = ../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(MOD_DEPTH)/config/autoconf.mk
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
CSRCS = \
|
||||
arena.c \
|
||||
base64t.c \
|
||||
getopt.c \
|
||||
string.c
|
||||
|
||||
ifeq (,$(filter-out WINCE WINNT OS2,$(OS_ARCH)))
|
||||
CSRCS += arena.c
|
||||
endif
|
||||
|
||||
ifeq (,$(filter-out WINCE WINNT OS2,$(OS_ARCH)))
|
||||
PROG_SUFFIX = .exe
|
||||
else
|
||||
PROG_SUFFIX =
|
||||
endif
|
||||
|
||||
PROGS = $(addprefix $(OBJDIR)/, $(CSRCS:.c=$(PROG_SUFFIX)))
|
||||
|
||||
TARGETS = $(PROGS) $(OBJS)
|
||||
|
||||
INCLUDES = -I$(dist_includedir)
|
||||
|
||||
# Setting the variables LDOPTS and LIBPR. We first initialize
|
||||
# them to the default values, then adjust them for some platforms.
|
||||
LDOPTS = -L$(dist_libdir)
|
||||
LIBPR = -lnspr$(MOD_MAJOR_VERSION)
|
||||
LIBPLC = -lplc$(MOD_MAJOR_VERSION)
|
||||
LIBPLDS = -lplds$(MOD_MAJOR_VERSION)
|
||||
|
||||
ifeq (,$(filter-out WINCE WINNT, $(OS_ARCH)))
|
||||
LDOPTS = -NOLOGO -DEBUG -INCREMENTAL:NO
|
||||
ifeq (,$(filter-out WIN95 WINCE WINMO, $(OS_TARGET)))
|
||||
LIBPR = $(dist_libdir)/nspr$(MOD_MAJOR_VERSION).$(LIB_SUFFIX)
|
||||
LIBPLC= $(dist_libdir)/plc$(MOD_MAJOR_VERSION).$(LIB_SUFFIX)
|
||||
LIBPLDS= $(dist_libdir)/plds$(MOD_MAJOR_VERSION).$(LIB_SUFFIX)
|
||||
else
|
||||
LIBPR = $(dist_libdir)/libnspr$(MOD_MAJOR_VERSION).$(LIB_SUFFIX)
|
||||
LIBPLC= $(dist_libdir)/libplc$(MOD_MAJOR_VERSION).$(LIB_SUFFIX)
|
||||
LIBPLDS= $(dist_libdir)/libplds$(MOD_MAJOR_VERSION).$(LIB_SUFFIX)
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(OS_ARCH),OS2)
|
||||
LDOPTS += -Zomf -Zlinker /PM:VIO
|
||||
endif
|
||||
|
||||
ifneq ($(OS_ARCH), WINNT)
|
||||
PWD = $(shell pwd)
|
||||
endif
|
||||
|
||||
ifeq ($(OS_ARCH), IRIX)
|
||||
LDOPTS += -rpath $(PWD)/$(dist_libdir)
|
||||
endif
|
||||
|
||||
ifeq ($(OS_ARCH), Linux)
|
||||
ifeq ($(OS_RELEASE), 1.2)
|
||||
EXTRA_LIBS = -ldl
|
||||
else
|
||||
LDOPTS += -Xlinker -rpath $(PWD)/$(dist_libdir)
|
||||
ifeq ($(USE_PTHREADS),1)
|
||||
EXTRA_LIBS = -lpthread
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq (,$(filter-out OpenBSD,$(OS_ARCH)))
|
||||
ifeq ($(USE_PTHREADS),1)
|
||||
EXTRA_LIBS = -lpthread
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(OS_ARCH), OSF1)
|
||||
LDOPTS += -rpath $(PWD)/$(dist_libdir) -lpthread
|
||||
endif
|
||||
|
||||
ifeq ($(OS_ARCH), HP-UX)
|
||||
LDOPTS += -Wl,+s,+b,$(PWD)/$(dist_libdir)
|
||||
endif
|
||||
|
||||
# AIX
|
||||
ifeq ($(OS_ARCH),AIX)
|
||||
LDOPTS += -blibpath:$(PWD)/$(dist_libdir):/usr/lib:/lib
|
||||
LIBPR = -lnspr$(MOD_MAJOR_VERSION)_shr
|
||||
LIBPLC = -lplc$(MOD_MAJOR_VERSION)_shr
|
||||
endif
|
||||
|
||||
# Solaris
|
||||
ifeq ($(OS_ARCH), SunOS)
|
||||
ifdef NS_USE_GCC
|
||||
LDOPTS += -Xlinker -R -Xlinker $(PWD)/$(dist_libdir)
|
||||
else
|
||||
LDOPTS += -R $(PWD)/$(dist_libdir)
|
||||
endif
|
||||
|
||||
# SunOS 5.5 needs to link with -lpthread, even though we already
|
||||
# linked with this system library when we built libnspr.so.
|
||||
ifeq ($(OS_RELEASE), 5.5)
|
||||
ifdef USE_PTHREADS
|
||||
EXTRA_LIBS = -lpthread
|
||||
endif
|
||||
endif
|
||||
endif # SunOS
|
||||
|
||||
#####################################################
|
||||
#
|
||||
# The rules
|
||||
#
|
||||
#####################################################
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
AIX_PRE_4_2 = 0
|
||||
ifeq ($(OS_ARCH),AIX)
|
||||
ifneq ($(OS_RELEASE),4.2)
|
||||
ifneq ($(USE_PTHREADS), 1)
|
||||
#AIX_PRE_4_2 = 1
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(AIX_PRE_4_2),1)
|
||||
|
||||
# AIX releases prior to 4.2 need a special two-step linking hack
|
||||
# in order to both override the system select() and be able to
|
||||
# get at the original system select().
|
||||
#
|
||||
# We use a pattern rule in ns/nspr20/config/rules.mk to generate
|
||||
# the .$(OBJ_SUFFIX) file from the .c source file, then do the
|
||||
# two-step linking hack below.
|
||||
|
||||
$(OBJDIR)/%: $(OBJDIR)/%.$(OBJ_SUFFIX)
|
||||
@$(MAKE_OBJDIR)
|
||||
rm -f $@ $(AIX_TMP)
|
||||
$(CC) $(AIX_LINK_OPTS) -o $(AIX_TMP) $< $(dist_libdir)/libnspr$(MOD_MAJOR_VERSION).a
|
||||
$(CC) -o $@ $(AIX_TMP) $(AIX_WRAP)
|
||||
rm -f $(AIX_TMP)
|
||||
|
||||
else
|
||||
|
||||
# All platforms that are not AIX pre-4.2.
|
||||
|
||||
$(OBJDIR)/%$(PROG_SUFFIX): $(OBJDIR)/%.$(OBJ_SUFFIX)
|
||||
@$(MAKE_OBJDIR)
|
||||
|
||||
ifeq ($(OS_ARCH), WINNT)
|
||||
link $(LDOPTS) $< $(LIBPLC) $(LIBPLDS) $(LIBPR) ws2_32.lib -out:$@
|
||||
else
|
||||
ifeq ($(OS_ARCH), WINCE)
|
||||
$(LD) $(LDOPTS) $< $(LIBPLC) $(LIBPLDS) $(LIBPR) ws2.lib -out:$@
|
||||
else
|
||||
ifeq ($(OS_ARCH),OS2)
|
||||
$(LINK) $(EXEFLAGS) $(LDOPTS) $< $(LIBPLC) $(LIBPLDS) $(LIBPR) $(OS_LIBS) $(EXTRA_LIBS)
|
||||
else
|
||||
$(CC) $(XCFLAGS) $< $(LDOPTS) $(LIBPLC) $(LIBPLDS) $(LIBPR) $(EXTRA_LIBS) -o $@
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
export:: $(TARGETS)
|
||||
clean::
|
||||
rm -f $(TARGETS)
|
||||
369
nsprpub/lib/tests/arena.c
Normal file
369
nsprpub/lib/tests/arena.c
Normal file
|
|
@ -0,0 +1,369 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
/*
|
||||
** File: arena.c
|
||||
** Description: Testing arenas
|
||||
**
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <stdlib.h>
|
||||
#include "nspr.h"
|
||||
#include "plarena.h"
|
||||
#include "plgetopt.h"
|
||||
|
||||
PRLogModuleInfo *tLM;
|
||||
PRIntn threadCount = 0;
|
||||
PRMonitor *tMon;
|
||||
PRBool failed_already = PR_FALSE;
|
||||
|
||||
/* Arguments from the command line with default values */
|
||||
PRIntn debug_mode = 0;
|
||||
PRIntn poolMin = 4096;
|
||||
PRIntn poolMax = (100 * 4096);
|
||||
PRIntn arenaMin = 40;
|
||||
PRIntn arenaMax = (100 * 40);
|
||||
PRIntn stressIterations = 15;
|
||||
PRIntn maxAlloc = (1024 * 1024);
|
||||
PRIntn stressThreads = 4;
|
||||
|
||||
void DumpAll( void )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
** Test Arena allocation.
|
||||
*/
|
||||
static void ArenaAllocate( void )
|
||||
{
|
||||
PLArenaPool ap;
|
||||
void *ptr;
|
||||
PRInt32 i;
|
||||
|
||||
PL_InitArenaPool( &ap, "AllocArena", 2048, sizeof(double));
|
||||
PR_LOG( tLM, PR_LOG_DEBUG, ("AA, InitPool -- Pool: %p. first: %p, current: %p, size: %d",
|
||||
&ap, ap.first, ap.current, ap.arenasize ));
|
||||
|
||||
for( i = 0; i < 150; i++ )
|
||||
{
|
||||
PL_ARENA_ALLOCATE( ptr, &ap, 512 );
|
||||
PR_LOG( tLM, PR_LOG_DEBUG,("AA, after alloc -- Pool: %p. first: %p, current: %p, size: %d",
|
||||
&ap, ap.first, ap.current, ap.arenasize ));
|
||||
PR_LOG( tLM, PR_LOG_DEBUG,(
|
||||
"AA -- Pool: %p. alloc: %p ", &ap, ptr ));
|
||||
}
|
||||
|
||||
PL_FreeArenaPool( &ap );
|
||||
|
||||
for( i = 0; i < 221; i++ )
|
||||
{
|
||||
PL_ARENA_ALLOCATE( ptr, &ap, 512 );
|
||||
PR_LOG( tLM, PR_LOG_DEBUG,("AA, after alloc -- Pool: %p. first: %p, current: %p, size: %d",
|
||||
&ap, ap.first, ap.current, ap.arenasize ));
|
||||
PR_LOG( tLM, PR_LOG_DEBUG,(
|
||||
"AA -- Pool: %p. alloc: %p ", &ap, ptr ));
|
||||
}
|
||||
|
||||
PL_FreeArenaPool( &ap );
|
||||
|
||||
return;
|
||||
} /* end ArenaGrow() */
|
||||
/*
|
||||
** Test Arena grow.
|
||||
*/
|
||||
static void ArenaGrow( void )
|
||||
{
|
||||
PLArenaPool ap;
|
||||
void *ptr;
|
||||
PRInt32 i;
|
||||
|
||||
PL_InitArenaPool( &ap, "TheArena", 4096, sizeof(double));
|
||||
PL_ARENA_ALLOCATE( ptr, &ap, 512 );
|
||||
|
||||
PR_LOG( tLM, PR_LOG_DEBUG, ("Before growth -- Pool: %p. alloc: %p ", &ap, ptr ));
|
||||
|
||||
for( i = 0; i < 10; i++ )
|
||||
{
|
||||
PL_ARENA_GROW( ptr, &ap, 512, 7000 );
|
||||
PR_LOG( tLM, PR_LOG_DEBUG, ("After growth -- Pool: %p. alloc: %p ", &ap, ptr ));
|
||||
}
|
||||
|
||||
|
||||
return;
|
||||
} /* end ArenaGrow() */
|
||||
|
||||
|
||||
/*
|
||||
** Test arena Mark and Release.
|
||||
*/
|
||||
static void MarkAndRelease( void )
|
||||
{
|
||||
PLArenaPool ap;
|
||||
void *ptr = NULL;
|
||||
void *mark0, *mark1;
|
||||
PRIntn i;
|
||||
|
||||
PL_InitArenaPool( &ap, "TheArena", 4096, sizeof(double));
|
||||
mark0 = PL_ARENA_MARK( &ap );
|
||||
PR_LOG( tLM, PR_LOG_DEBUG,
|
||||
("mark0. ap: %p, ap.f: %p, ap.c: %p, ap.siz: %d, alloc: %p, m0: %p",
|
||||
&ap, ap.first.next, ap.current, ap.arenasize, ptr, mark0 ));
|
||||
|
||||
for( i = 0; i < 201; i++ )
|
||||
{
|
||||
PL_ARENA_ALLOCATE( ptr, &ap, 512 );
|
||||
PR_LOG( tLM, PR_LOG_DEBUG,
|
||||
("mr. ap: %p, ap.f: %p, ap.c: %p, ap.siz: %d, alloc: %p",
|
||||
&ap, ap.first.next, ap.current, ap.arenasize, ptr ));
|
||||
}
|
||||
|
||||
mark1 = PL_ARENA_MARK( &ap );
|
||||
PR_LOG( tLM, PR_LOG_DEBUG,
|
||||
("mark1. ap: %p, ap.f: %p, ap.c: %p, ap.siz: %d, alloc: %p, m1: %p",
|
||||
&ap, ap.first.next, ap.current, ap.arenasize, ptr, mark1 ));
|
||||
|
||||
|
||||
for( i = 0; i < 225; i++ )
|
||||
{
|
||||
PL_ARENA_ALLOCATE( ptr, &ap, 512 );
|
||||
PR_LOG( tLM, PR_LOG_DEBUG,
|
||||
("mr. ap: %p, ap.f: %p, ap.c: %p, ap.siz: %d, alloc: %p",
|
||||
&ap, ap.first.next, ap.current, ap.arenasize, ptr ));
|
||||
}
|
||||
|
||||
PL_ARENA_RELEASE( &ap, mark1 );
|
||||
PR_LOG( tLM, PR_LOG_DEBUG,
|
||||
("Release-1: %p -- Pool: %p. first: %p, current: %p, size: %d",
|
||||
mark1, &ap, ap.first, ap.current, ap.arenasize ));
|
||||
|
||||
for( i = 0; i < 20; i++ )
|
||||
{
|
||||
PL_ARENA_ALLOCATE( ptr, &ap, 512 );
|
||||
PR_LOG( tLM, PR_LOG_DEBUG,
|
||||
("mr. ap: %p, ap.f: %p, ap.c: %p, ap.siz: %d, alloc: %p",
|
||||
&ap, ap.first.next, ap.current, ap.arenasize, ptr ));
|
||||
}
|
||||
|
||||
PL_ARENA_RELEASE( &ap, mark1 );
|
||||
PR_LOG( tLM, PR_LOG_DEBUG,
|
||||
("Release-1. ap: %p, ap.f: %p, ap.c: %p, ap.siz: %d, alloc: %p",
|
||||
&ap, ap.first.next, ap.current, ap.arenasize, ptr ));
|
||||
|
||||
PL_ARENA_RELEASE( &ap, mark0 );
|
||||
PR_LOG( tLM, PR_LOG_DEBUG,
|
||||
("Release-0. ap: %p, ap.f: %p, ap.c: %p, ap.siz: %d, alloc: %p",
|
||||
&ap, ap.first.next, ap.current, ap.arenasize, ptr ));
|
||||
|
||||
PL_FreeArenaPool( &ap );
|
||||
PR_LOG( tLM, PR_LOG_DEBUG,
|
||||
("Free. ap: %p, ap.f: %p, ap.c: %p, ap.siz: %d, alloc: %p",
|
||||
&ap, ap.first.next, ap.current, ap.arenasize, ptr ));
|
||||
|
||||
PL_FinishArenaPool( &ap );
|
||||
PR_LOG( tLM, PR_LOG_DEBUG,
|
||||
("Finish. ap: %p, ap.f: %p, ap.c: %p, ap.siz: %d, alloc: %p",
|
||||
&ap, ap.first.next, ap.current, ap.arenasize, ptr ));
|
||||
|
||||
return;
|
||||
} /* end MarkAndRelease() */
|
||||
|
||||
/*
|
||||
** RandSize() returns a random number in the range
|
||||
** min..max, rounded to the next doubleword
|
||||
**
|
||||
*/
|
||||
static PRIntn RandSize( PRIntn min, PRIntn max )
|
||||
{
|
||||
PRIntn sz = (rand() % (max -min)) + min + sizeof(double);
|
||||
|
||||
sz &= ~sizeof(double)-1;
|
||||
|
||||
return(sz);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** StressThread()
|
||||
** A bunch of these beat on individual arenas
|
||||
** This tests the free_list protection.
|
||||
**
|
||||
*/
|
||||
static void PR_CALLBACK StressThread( void *arg )
|
||||
{
|
||||
PLArenaPool ap;
|
||||
PRIntn i;
|
||||
PRIntn sz;
|
||||
void *ptr;
|
||||
PRThread *tp = PR_GetCurrentThread();
|
||||
|
||||
PR_LOG( tLM, PR_LOG_DEBUG, ("Stress Thread %p started\n", PR_GetCurrentThread()));
|
||||
PL_InitArenaPool( &ap, "TheArena", RandSize( poolMin, poolMax), sizeof(double));
|
||||
|
||||
for ( i = 0; i < stressIterations; i++ )
|
||||
{
|
||||
PRIntn allocated = 0;
|
||||
|
||||
while ( allocated < maxAlloc )
|
||||
{
|
||||
sz = RandSize( arenaMin, arenaMax );
|
||||
PL_ARENA_ALLOCATE( ptr, &ap, sz );
|
||||
if ( ptr == NULL )
|
||||
{
|
||||
PR_LOG( tLM, PR_LOG_ERROR, ("ARENA_ALLOCATE() returned NULL\n\tAllocated: %d\n", allocated));
|
||||
break;
|
||||
}
|
||||
allocated += sz;
|
||||
}
|
||||
PR_LOG( tLM, PR_LOG_DEBUG, ("Stress thread %p finished one iteration\n", tp));
|
||||
PL_FreeArenaPool( &ap );
|
||||
}
|
||||
PR_LOG( tLM, PR_LOG_DEBUG, ("Stress thread %p finished all iteration\n", tp));
|
||||
PL_FinishArenaPool( &ap );
|
||||
PR_LOG( tLM, PR_LOG_DEBUG, ("Stress thread %p after FinishArenaPool()\n", tp));
|
||||
|
||||
/* That's all folks! let's quit */
|
||||
PR_EnterMonitor(tMon);
|
||||
threadCount--;
|
||||
PR_Notify(tMon);
|
||||
PR_ExitMonitor(tMon);
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
** Stress()
|
||||
** Flog the hell out of arenas multi-threaded.
|
||||
** Do NOT pass an individual arena to another thread.
|
||||
**
|
||||
*/
|
||||
static void Stress( void )
|
||||
{
|
||||
PRThread *tt;
|
||||
PRIntn i;
|
||||
|
||||
tMon = PR_NewMonitor();
|
||||
|
||||
for ( i = 0 ; i < stressThreads ; i++ )
|
||||
{
|
||||
PR_EnterMonitor(tMon);
|
||||
tt = PR_CreateThread(PR_USER_THREAD,
|
||||
StressThread,
|
||||
NULL,
|
||||
PR_PRIORITY_NORMAL,
|
||||
PR_GLOBAL_THREAD,
|
||||
PR_UNJOINABLE_THREAD,
|
||||
0);
|
||||
threadCount++;
|
||||
PR_ExitMonitor(tMon);
|
||||
}
|
||||
|
||||
/* Wait for all threads to exit */
|
||||
PR_EnterMonitor(tMon);
|
||||
while ( threadCount != 0 )
|
||||
{
|
||||
PR_Wait(tMon, PR_INTERVAL_NO_TIMEOUT);
|
||||
}
|
||||
PR_ExitMonitor(tMon);
|
||||
PR_DestroyMonitor(tMon);
|
||||
|
||||
return;
|
||||
} /* end Stress() */
|
||||
|
||||
/*
|
||||
** EvaluateResults()
|
||||
** uses failed_already to display results and set program
|
||||
** exit code.
|
||||
*/
|
||||
static PRIntn EvaluateResults(void)
|
||||
{
|
||||
PRIntn rc = 0;
|
||||
|
||||
if ( failed_already == PR_TRUE )
|
||||
{
|
||||
PR_LOG( tLM, PR_LOG_DEBUG, ("FAIL\n"));
|
||||
rc =1;
|
||||
}
|
||||
else
|
||||
{
|
||||
PR_LOG( tLM, PR_LOG_DEBUG, ("PASS\n"));
|
||||
}
|
||||
return(rc);
|
||||
} /* EvaluateResults() */
|
||||
|
||||
void Help( void )
|
||||
{
|
||||
printf("arena [options]\n");
|
||||
printf("where options are:\n");
|
||||
printf("-p <n> minimum size of an arena pool. Default(%d)\n", poolMin);
|
||||
printf("-P <n> maximum size of an arena pool. Default(%d)\n", poolMax);
|
||||
printf("-a <n> minimum size of an arena allocation. Default(%d)\n", arenaMin);
|
||||
printf("-A <n> maximum size of an arena allocation. Default(%d)\n", arenaMax);
|
||||
printf("-i <n> number of iterations in a stress thread. Default(%d)\n", stressIterations);
|
||||
printf("-s <n> maximum allocation for a single stress thread. Default(%d)\n", maxAlloc);
|
||||
printf("-t <n> number of stress threads. Default(%d)\n", stressThreads );
|
||||
printf("-d enable debug mode\n");
|
||||
printf("\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
PRIntn main(PRIntn argc, char *argv[])
|
||||
{
|
||||
PLOptStatus os;
|
||||
PLOptState *opt = PL_CreateOptState(argc, argv, "dhp:P:a:A:i:s:t:");
|
||||
while (PL_OPT_EOL != (os = PL_GetNextOpt(opt)))
|
||||
{
|
||||
if (PL_OPT_BAD == os) continue;
|
||||
switch (opt->option)
|
||||
{
|
||||
case 'a': /* arena Min size */
|
||||
arenaMin = atol( opt->value );
|
||||
break;
|
||||
case 'A': /* arena Max size */
|
||||
arenaMax = atol( opt->value );
|
||||
break;
|
||||
case 'p': /* pool Min size */
|
||||
poolMin = atol( opt->value );
|
||||
break;
|
||||
case 'P': /* pool Max size */
|
||||
poolMax = atol( opt->value );
|
||||
break;
|
||||
case 'i': /* Iterations in stress tests */
|
||||
stressIterations = atol( opt->value );
|
||||
break;
|
||||
case 's': /* storage to get per iteration */
|
||||
maxAlloc = atol( opt->value );
|
||||
break;
|
||||
case 't': /* Number of stress threads to create */
|
||||
stressThreads = atol( opt->value );
|
||||
break;
|
||||
case 'd': /* debug mode */
|
||||
debug_mode = 1;
|
||||
break;
|
||||
case 'h': /* help */
|
||||
default:
|
||||
Help();
|
||||
} /* end switch() */
|
||||
} /* end while() */
|
||||
PL_DestroyOptState(opt);
|
||||
|
||||
srand( (unsigned)time( NULL ) ); /* seed random number generator */
|
||||
tLM = PR_NewLogModule("testcase");
|
||||
|
||||
|
||||
#if 0
|
||||
ArenaAllocate();
|
||||
ArenaGrow();
|
||||
#endif
|
||||
|
||||
MarkAndRelease();
|
||||
|
||||
Stress();
|
||||
|
||||
return(EvaluateResults());
|
||||
} /* end main() */
|
||||
|
||||
/* arena.c */
|
||||
3015
nsprpub/lib/tests/base64t.c
Normal file
3015
nsprpub/lib/tests/base64t.c
Normal file
File diff suppressed because it is too large
Load diff
44
nsprpub/lib/tests/getopt.c
Normal file
44
nsprpub/lib/tests/getopt.c
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "nspr.h"
|
||||
#include "plgetopt.h"
|
||||
|
||||
|
||||
|
||||
static const PLLongOpt optArray[] = {
|
||||
{ "longa", 'a' , PR_TRUE },
|
||||
{ "longb", 'b' , PR_TRUE },
|
||||
{ "longc", 'c' , PR_FALSE },
|
||||
{ "longd", 'd' | 0x100, PR_TRUE },
|
||||
{ "longe", 'e' | 0x100, PR_FALSE },
|
||||
{ NULL, }
|
||||
};
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
PLOptState *opt;
|
||||
PLOptStatus ostat;
|
||||
|
||||
opt = PL_CreateLongOptState(argc, argv, "a:b:c", optArray);
|
||||
|
||||
while (PL_OPT_OK == (ostat = PL_GetNextOpt(opt))) {
|
||||
if (opt->option == 0 && opt->longOptIndex < 0)
|
||||
printf("Positional parameter: \"%s\"\n", opt->value);
|
||||
else
|
||||
printf("%s option: %x (\'%c\', index %d), argument: \"%s\"\n",
|
||||
(ostat == PL_OPT_BAD) ? "BAD" : "GOOD",
|
||||
opt->longOption, opt->option ? opt->option : ' ',
|
||||
opt->longOptIndex, opt->value);
|
||||
|
||||
}
|
||||
printf("last result was %s\n", (ostat == PL_OPT_BAD) ? "BAD" : "EOL");
|
||||
PL_DestroyOptState(opt);
|
||||
return 0;
|
||||
}
|
||||
3084
nsprpub/lib/tests/string.c
Normal file
3084
nsprpub/lib/tests/string.c
Normal file
File diff suppressed because it is too large
Load diff
29
nsprpub/pkg/Makefile.in
Normal file
29
nsprpub/pkg/Makefile.in
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
#
|
||||
# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
|
||||
# Use is subject to license terms.
|
||||
#
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
#! gmake
|
||||
|
||||
MOD_DEPTH = ..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(MOD_DEPTH)/config/autoconf.mk
|
||||
|
||||
DIRS =
|
||||
ifeq ($(OS_TARGET),Linux)
|
||||
DIRS = linux
|
||||
endif
|
||||
ifeq ($(OS_TARGET),SunOS)
|
||||
DIRS = solaris
|
||||
endif
|
||||
|
||||
publish::
|
||||
+$(LOOP_OVER_DIRS)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
80
nsprpub/pkg/linux/Makefile.in
Normal file
80
nsprpub/pkg/linux/Makefile.in
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
#
|
||||
# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
|
||||
# Use is subject to license terms.
|
||||
#
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#
|
||||
#ident "$Id$"
|
||||
#
|
||||
|
||||
MOD_DEPTH = ../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
NAME = sun-nspr
|
||||
ifndef RPM_RELEASE
|
||||
RPM_RELEASE = 1
|
||||
endif
|
||||
TOPDIR = /usr/src/redhat
|
||||
VERSION = `grep PR_VERSION $(dist_includedir)/prinit.h \
|
||||
| sed -e 's/"$$//' -e 's/.*"//' -e 's/ .*//'`
|
||||
|
||||
SPECFILE = $(NAME).spec
|
||||
|
||||
include $(MOD_DEPTH)/config/autoconf.mk
|
||||
|
||||
# Force i386 for non 64 bit build
|
||||
ifneq ($(USE_64),1)
|
||||
RPMTARGET = "--target=i386"
|
||||
RPMLIBDIR = lib
|
||||
else
|
||||
RPMLIBDIR = lib64
|
||||
endif
|
||||
|
||||
publish:
|
||||
$(MAKE) clean
|
||||
mkdir -p SOURCES SRPMS RPMS BUILD
|
||||
(cd $(dist_libdir) && tar cphf - libnspr4.so libplds4.so libplc4.so) \
|
||||
| (mkdir -p opt/sun/private/$(RPMLIBDIR) && cd opt/sun/private/$(RPMLIBDIR) && tar xvfBp -)
|
||||
(cd $(dist_includedir) && tar cphf - .) \
|
||||
| (mkdir -p opt/sun/private/include/nspr && cd opt/sun/private/include/nspr && tar xvfBp -)
|
||||
(cd opt/sun/private/include/nspr && \
|
||||
rm -rf md)
|
||||
tar czvf SOURCES/$(NAME)-$(VERSION).tar.gz opt
|
||||
echo "%define name $(NAME)" >$(SPECFILE)
|
||||
echo "%define version $(VERSION)" >>$(SPECFILE)
|
||||
echo "%define release $(RPM_RELEASE)" >>$(SPECFILE)
|
||||
echo "%define buildroot `pwd`/$(NAME)-root" >>$(SPECFILE)
|
||||
echo "%define _topdir `pwd`" >>$(SPECFILE)
|
||||
echo "%define _unpackaged_files_terminate_build 0" >>$(SPECFILE)
|
||||
cat $(srcdir)/$(NAME).spec >>$(SPECFILE)
|
||||
echo "" >>$(SPECFILE)
|
||||
echo "%files" >>$(SPECFILE)
|
||||
echo "%defattr(-,root,root)" >>$(SPECFILE)
|
||||
echo "%dir /opt" >>$(SPECFILE)
|
||||
echo "%dir /opt/sun" >>$(SPECFILE)
|
||||
echo "%dir /opt/sun/private" >>$(SPECFILE)
|
||||
echo "%dir /opt/sun/private/$(RPMLIBDIR)" >>$(SPECFILE)
|
||||
find opt \( -name "*.so" \) | sed -e "s-^-/-" >>$(SPECFILE)
|
||||
echo "" >>$(SPECFILE)
|
||||
echo "%files devel" >>$(SPECFILE)
|
||||
echo "%defattr(-,root,root)" >>$(SPECFILE)
|
||||
echo "%dir /opt" >>$(SPECFILE)
|
||||
echo "%dir /opt/sun" >>$(SPECFILE)
|
||||
echo "%dir /opt/sun/private" >>$(SPECFILE)
|
||||
echo "%dir /opt/sun/private/include" >>$(SPECFILE)
|
||||
echo "%dir /opt/sun/private/include/nspr" >>$(SPECFILE)
|
||||
echo "%dir /opt/sun/private/include/nspr/obsolete" >>$(SPECFILE)
|
||||
echo "%dir /opt/sun/private/include/nspr/private" >>$(SPECFILE)
|
||||
find opt -type f \( -name "*.h" \) \
|
||||
| sed -e "s-^-/-" >>$(SPECFILE)
|
||||
rpmbuild $(RPMTARGET) -bb $(SPECFILE)
|
||||
|
||||
clean:
|
||||
rm -rf $(TOPDIR)/BUILD/$(NAME)
|
||||
rm -rf SOURCES SRPMS RPMS BUILD
|
||||
rm -rf RPMS SRPMS opt
|
||||
rm -f $(NAME)-$(VERSION).tar.gz
|
||||
49
nsprpub/pkg/linux/sun-nspr.spec
Normal file
49
nsprpub/pkg/linux/sun-nspr.spec
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
Summary: Netscape Portable Runtime
|
||||
Name: %{name}
|
||||
Vendor: Sun Microsystems, Inc.
|
||||
Version: %{version}
|
||||
Release: %{release}
|
||||
Copyright: Copyright 2005 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms. Also under other license(s) as shown at the Description field.
|
||||
Distribution: Sun Java(TM) Enterprise System
|
||||
URL: http://www.sun.com
|
||||
Group: System Environment/Base
|
||||
Source: %{name}-%{version}.tar.gz
|
||||
ExclusiveOS: Linux
|
||||
BuildRoot: /var/tmp/%{name}-root
|
||||
|
||||
%description
|
||||
|
||||
NSPR provides platform independence for non-GUI operating system
|
||||
facilities. These facilities include threads, thread synchronization,
|
||||
normal file and network I/O, interval timing and calendar time, basic
|
||||
memory management (malloc and free) and shared library linking.
|
||||
|
||||
See: http://www.mozilla.org/projects/nspr/about-nspr.html
|
||||
|
||||
This Source Code Form is subject to the terms of the Mozilla Public
|
||||
License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
%package devel
|
||||
Summary: Development Libraries for the Netscape Portable Runtime
|
||||
Group: Development/Libraries
|
||||
Requires: %{name} = %{version}-%{release}
|
||||
|
||||
%description devel
|
||||
Header files for doing development with the Netscape Portable Runtime.
|
||||
|
||||
Under "MPL/GPL" license.
|
||||
|
||||
%prep
|
||||
%setup -c
|
||||
|
||||
%build
|
||||
|
||||
%install
|
||||
rm -rf $RPM_BUILD_ROOT
|
||||
mkdir $RPM_BUILD_ROOT
|
||||
cd $RPM_BUILD_ROOT
|
||||
tar xvzf $RPM_SOURCE_DIR/%{name}-%{version}.tar.gz
|
||||
|
||||
%clean
|
||||
rm -rf $RPM_BUILD_ROOT
|
||||
34
nsprpub/pkg/solaris/Makefile-devl.com
Normal file
34
nsprpub/pkg/solaris/Makefile-devl.com
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
#
|
||||
# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
|
||||
# Use is subject to license terms.
|
||||
#
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#
|
||||
#ident "$Id$"
|
||||
#
|
||||
|
||||
MACH = $(shell mach)
|
||||
|
||||
PUBLISH_ROOT = $(DIST)
|
||||
ifeq ($(MOD_DEPTH),../..)
|
||||
ROOT = ROOT
|
||||
else
|
||||
ROOT = $(subst ../../,,$(MOD_DEPTH))/ROOT
|
||||
endif
|
||||
|
||||
PKGARCHIVE = $(dist_prefix)/pkgarchive
|
||||
DATAFILES = copyright
|
||||
FILES = $(DATAFILES) pkginfo
|
||||
|
||||
PACKAGE = $(shell basename `pwd`)
|
||||
|
||||
PRODUCT_VERSION = "$(MOD_VERSION).$(MOD_MINOR).$(MOD_PATCH)$(MOD_BETA)"
|
||||
LN = /usr/bin/ln
|
||||
|
||||
CLOBBERFILES = $(FILES)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
# vim: ft=make
|
||||
34
nsprpub/pkg/solaris/Makefile-devl.targ
Normal file
34
nsprpub/pkg/solaris/Makefile-devl.targ
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
#
|
||||
# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
|
||||
# Use is subject to license terms.
|
||||
#
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#
|
||||
#ident "$Id$"
|
||||
#
|
||||
|
||||
include $(srcdir)/../proto64.mk
|
||||
|
||||
pkginfo: pkginfo.tmpl ../awk_pkginfo
|
||||
$(RM) $@; nawk -f ../awk_pkginfo $(srcdir)/$@.tmpl > $@
|
||||
|
||||
pkg: $(PKGARCHIVE)
|
||||
cat $(srcdir)/prototype | sed $(sed_proto64) > prototype
|
||||
cp $(srcdir)/depend .
|
||||
pkgmk -f prototype -d $(PKGARCHIVE) -r $(ROOT) -o $(PACKAGE)
|
||||
|
||||
$(PKGARCHIVE):
|
||||
[ -d $(PKGARCHIVE) ] || mkdir -p $(PKGARCHIVE)
|
||||
|
||||
$(DATAFILES): %: $(srcdir)/../common_files/%
|
||||
$(RM) $@; cp $(srcdir)/../common_files/$@ $@
|
||||
|
||||
$(MACHDATAFILES): %: $(srcdir)/../common_files/%_$(MACH)
|
||||
$(RM) $@; cp $(srcdir)/../common_files/$@_$(MACH) $@
|
||||
|
||||
clobber clean::
|
||||
-$(RM) $(CLOBBERFILES) $(CLEANFILES)
|
||||
|
||||
.PHONY: pkg
|
||||
37
nsprpub/pkg/solaris/Makefile.com
Normal file
37
nsprpub/pkg/solaris/Makefile.com
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
#
|
||||
# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
|
||||
# Use is subject to license terms.
|
||||
#
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#
|
||||
#ident "$Id$"
|
||||
#
|
||||
|
||||
MACH = $(shell mach)
|
||||
|
||||
PUBLISH_ROOT = $(DIST)
|
||||
ifeq ($(MOD_DEPTH),../..)
|
||||
ROOT = ROOT
|
||||
else
|
||||
ROOT = $(subst ../../,,$(MOD_DEPTH))/ROOT
|
||||
endif
|
||||
|
||||
PKGARCHIVE = $(dist_prefix)/pkgarchive
|
||||
DATAFILES = copyright
|
||||
FILES = $(DATAFILES) pkginfo
|
||||
|
||||
PACKAGE = $(shell basename `pwd`)
|
||||
|
||||
PRODUCT_VERSION = $(shell grep PR_VERSION $(dist_includedir)/prinit.h \
|
||||
| sed -e 's/"$$//' -e 's/.*"//' -e 's/ .*//')
|
||||
|
||||
LN = /usr/bin/ln
|
||||
CP = /usr/bin/cp
|
||||
|
||||
CLOBBERFILES = $(FILES)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
# vim: ft=make
|
||||
89
nsprpub/pkg/solaris/Makefile.in
Normal file
89
nsprpub/pkg/solaris/Makefile.in
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
#
|
||||
# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
|
||||
# Use is subject to license terms.
|
||||
#
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#
|
||||
#ident "$Id$"
|
||||
#
|
||||
|
||||
MOD_DEPTH = ../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(MOD_DEPTH)/config/autoconf.mk
|
||||
|
||||
abs_dist_libdir := $(shell (cd $(dist_libdir);pwd))
|
||||
abs_dist_includedir := $(shell (cd $(dist_includedir);pwd))
|
||||
|
||||
%: %.ksh
|
||||
$(RM) $@
|
||||
cp $< $@
|
||||
chmod +x $@
|
||||
|
||||
DIRS = \
|
||||
SUNWpr \
|
||||
SUNWprd
|
||||
|
||||
include $(srcdir)/Makefile.com
|
||||
|
||||
PROTO = \
|
||||
$(ROOT) \
|
||||
$(ROOT)/usr/lib/mps \
|
||||
$(ROOT)/usr/include/mps
|
||||
|
||||
ifeq ($(MACH), sparc)
|
||||
PROTO += $(ROOT)/usr/lib/mps/cpu/sparcv8plus
|
||||
endif
|
||||
|
||||
ifeq ($(USE_64), 1)
|
||||
ifeq ($(MACH), sparc)
|
||||
# Sparc
|
||||
PROTO += $(ROOT)/usr/lib/mps/sparcv9
|
||||
else
|
||||
# AMD64
|
||||
PROTO += $(ROOT)/usr/lib/mps/amd64
|
||||
endif
|
||||
abs_dist64_libdir = $(abs_dist_libdir)
|
||||
abs_dist32_libdir = $(shell echo $(abs_dist_libdir) | sed -e "s|_64_OPT|_OPT|g" -e "s|_64_DBG|_DBG|g")
|
||||
abs_dist64_includedir = $(abs_dist_includedir)
|
||||
abs_dist32_includedir = $(shell echo $(abs_dist_includedir) | sed -e "s|_64_OPT|_OPT|g" -e "s|_64_DBG|_DBG|g")
|
||||
else
|
||||
abs_dist32_libdir = $(abs_dist_libdir)
|
||||
abs_dist64_libdir = $(shell echo $(abs_dist_libdir) | sed -e "s|_OPT|_64_OPT|g" -e "s|_DBG|_64_DBG|g")
|
||||
abs_dist32_includedir = $(abs_dist_includedir)
|
||||
abs_dist64_includedir = $(shell echo $(abs_dist_includedir) | sed -e "s|_OPT|_64_OPT|g" -e "s|_DBG|_64_DBG|g")
|
||||
endif
|
||||
|
||||
awk_pkginfo: bld_awk_pkginfo
|
||||
./bld_awk_pkginfo -m $(MACH) -p "$(PRODUCT_VERSION)" -o $@ -v $(PRODUCT_VERSION)
|
||||
|
||||
all:: awk_pkginfo $(PROTO)
|
||||
publish: awk_pkginfo $(PROTO)
|
||||
+$(LOOP_OVER_DIRS)
|
||||
|
||||
clean clobber::
|
||||
$(RM) awk_pkginfo bld_awk_pkginfo
|
||||
$(RM) -r $(ROOT)
|
||||
|
||||
$(ROOT):
|
||||
mkdir -p $@
|
||||
|
||||
$(ROOT)/usr/lib/mps/sparcv9:
|
||||
mkdir -p $@
|
||||
$(CP) -r $(abs_dist64_libdir)/*.so $@
|
||||
$(ROOT)/usr/lib/mps/amd64:
|
||||
mkdir -p $@
|
||||
$(CP) -r $(abs_dist64_libdir)/*.so $@
|
||||
$(ROOT)/usr/lib/mps:
|
||||
mkdir -p $@
|
||||
$(CP) -r $(abs_dist32_libdir)/*.so $@
|
||||
$(ROOT)/usr/lib/mps/cpu/sparcv8plus:
|
||||
mkdir -p $@
|
||||
$(CP) -r $(abs_dist32_libdir)/cpu/sparcv8plus/*.so $@
|
||||
$(ROOT)/usr/include/mps:
|
||||
mkdir -p $@
|
||||
$(CP) -r $(abs_dist32_includedir)/* $@
|
||||
32
nsprpub/pkg/solaris/Makefile.targ
Normal file
32
nsprpub/pkg/solaris/Makefile.targ
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
#
|
||||
# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
|
||||
# Use is subject to license terms.
|
||||
#
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#
|
||||
#ident "$Id$"
|
||||
#
|
||||
|
||||
include $(srcdir)/../proto64.mk
|
||||
|
||||
pkginfo: pkginfo.tmpl ../awk_pkginfo
|
||||
$(RM) $@; nawk -f ../awk_pkginfo $< > $@
|
||||
|
||||
pkg: $(PKGARCHIVE) prototype_$(MACH)
|
||||
cp $(srcdir)/prototype_com .
|
||||
cat $(srcdir)/prototype_$(MACH) | sed $(sed_proto64) > prototype_$(MACH)
|
||||
cp $(srcdir)/depend .
|
||||
pkgmk -f prototype_$(MACH) -d $(PKGARCHIVE) -r $(ROOT) -o $(PACKAGE)
|
||||
|
||||
$(PKGARCHIVE):
|
||||
[ -d $(PKGARCHIVE) ] || mkdir -p $(PKGARCHIVE)
|
||||
|
||||
$(DATAFILES): %: $(srcdir)/../common_files/%
|
||||
$(RM) $@; cp $(srcdir)/../common_files/$@ $@
|
||||
|
||||
clobber clean::
|
||||
-$(RM) $(CLOBBERFILES) $(CLEANFILES)
|
||||
|
||||
.PHONY: pkg
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue