mirror of
https://github.com/tildearrow/furnace.git
synced 2024-11-01 02:22:39 +00:00
use macports-legacy-support for OS X
disabled for macOS onwards modified version without APSL licensed files
This commit is contained in:
parent
9f88941455
commit
8b43d5a488
76 changed files with 5602 additions and 0 deletions
|
@ -759,6 +759,13 @@ if (WIN32)
|
|||
list(APPEND ENGINE_SOURCES res/furnace.rc)
|
||||
endif()
|
||||
|
||||
if (APPLE)
|
||||
if (CMAKE_OSX_DEPLOYMENT_TARGET VERSION_LESS 10.12)
|
||||
list(APPEND DEPENDENCIES_INCLUDE_DIRS extern/macports-legacy-support/include)
|
||||
list(APPEND ENGINE_SOURCES extern/macports-legacy-support/src/time.c)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(CLI_SOURCES
|
||||
src/cli/cli.cpp
|
||||
)
|
||||
|
|
7
extern/macports-legacy-support/.gitignore
vendored
Normal file
7
extern/macports-legacy-support/.gitignore
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
*.o
|
||||
*.o.*
|
||||
*.d
|
||||
*.dylib
|
||||
lib
|
||||
*~
|
||||
*.dSYM
|
3
extern/macports-legacy-support/.travis.yml
vendored
Normal file
3
extern/macports-legacy-support/.travis.yml
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
language: c
|
||||
os: osx
|
||||
script: make && sudo make install && make test
|
38
extern/macports-legacy-support/BUILDING.txt
vendored
Normal file
38
extern/macports-legacy-support/BUILDING.txt
vendored
Normal file
|
@ -0,0 +1,38 @@
|
|||
## Building
|
||||
|
||||
Usual Makefile project. This project does not require a configure phase.
|
||||
|
||||
### Special optional variables
|
||||
|
||||
# `PLATFORM`
|
||||
|
||||
Darwin version to target against. Detected automatically, but can also
|
||||
be overridden manually to test builds for other OS versions.
|
||||
(This is not the macOS version.)
|
||||
|
||||
# `FORCE_ARCH`
|
||||
|
||||
Architecture to build for. Accepts a single value, not a list.
|
||||
|
||||
If your `lipo` binary is new enough and supports the `-archs` flag, you will
|
||||
not need to use this variable. Instead, directly build the software
|
||||
universally in one pass using the usual `-arch` compiler flags. The
|
||||
autodetection, split and merge features will then handle the different
|
||||
architectures automatically.
|
||||
|
||||
Older versions of `lipo` do not support the `-archs` flag, so automatic
|
||||
architecture detection via binary/object file inspection is not be possible
|
||||
on older platforms.
|
||||
|
||||
In order to avoid an additional dependency on the `cctools` port
|
||||
to provide a newer `lipo` version, this variable was introduced.
|
||||
It disables the automatic architecture detection feature and instead
|
||||
hardcodes the contained value as the target architecture.
|
||||
|
||||
Within `MacPorts`, we use it in multi-architecture builds with one
|
||||
pass per architecture. Finally, the `MacPorts ``muniversal` PortGroup
|
||||
will merge the resulting binaries into one fat/universal binary automatically.
|
||||
|
||||
Some symbols must be built multiple times. Each variant will use a different
|
||||
data layout and have a special postfix appended to it. The data layouts
|
||||
supported and needed depend upon the architecture and (target) OS version.
|
19
extern/macports-legacy-support/LICENSE
vendored
Normal file
19
extern/macports-legacy-support/LICENSE
vendored
Normal file
|
@ -0,0 +1,19 @@
|
|||
All the files under Apple Public Source License have been removed for compliance.
|
||||
The remaining files are under MIT License.
|
||||
|
||||
Parts of this project that have been created by members of the MacPorts community
|
||||
are under the MIT License
|
||||
|
||||
Copyright (c) 2018-2020 Chris Jones, Michael Dickens
|
||||
Mihai Moldovan, and many other contributing members of the MacPorts community
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
346
extern/macports-legacy-support/Makefile
vendored
Normal file
346
extern/macports-legacy-support/Makefile
vendored
Normal file
|
@ -0,0 +1,346 @@
|
|||
# GNU Makefile for MacportsLegacySupport
|
||||
# Copyright (c) 2018 Chris Jones <jonesc@macports.org>
|
||||
# Copyright (c) 2019 Michael Dickens <michaelld@macports.org>
|
||||
#
|
||||
# Permission to use, copy, modify, and distribute this software for any
|
||||
# purpose with or without fee is hereby granted, provided that the above
|
||||
# copyright notice and this permission notice appear in all copies.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
DESTDIR ?=
|
||||
PREFIX ?= /usr/local
|
||||
INCSUBDIR = LegacySupport
|
||||
PKGINCDIR = $(PREFIX)/include/$(INCSUBDIR)
|
||||
LIBDIR = $(PREFIX)/lib
|
||||
AREXT = .a
|
||||
SOEXT = .dylib
|
||||
LIBNAME = MacportsLegacySupport
|
||||
SYSLIBNAME = MacportsLegacySystem.B
|
||||
DLIBFILE = lib$(LIBNAME)$(SOEXT)
|
||||
SLIBFILE = lib$(LIBNAME)$(AREXT)
|
||||
SYSLIBFILE = lib$(SYSLIBNAME)$(SOEXT)
|
||||
DLIBPATH = $(LIBDIR)/$(DLIBFILE)
|
||||
SLIBPATH = $(LIBDIR)/$(SLIBFILE)
|
||||
SYSLIBPATH = $(LIBDIR)/$(SYSLIBFILE)
|
||||
BUILDDLIBDIR = lib
|
||||
BUILDSLIBDIR = lib
|
||||
BUILDDLIBPATH = $(BUILDDLIBDIR)/$(DLIBFILE)
|
||||
BUILDSLIBPATH = $(BUILDSLIBDIR)/$(SLIBFILE)
|
||||
BUILDSYSLIBPATH = $(BUILDDLIBDIR)/$(SYSLIBFILE)
|
||||
SOCURVERSION ?= 1.0
|
||||
SOCOMPATVERSION ?= 1.0
|
||||
BUILDDLIBFLAGS = -dynamiclib -headerpad_max_install_names \
|
||||
-install_name @executable_path/../$(BUILDDLIBPATH) \
|
||||
-current_version $(SOCURVERSION) \
|
||||
-compatibility_version $(SOCOMPATVERSION)
|
||||
BUILDSYSLIBFLAGS = -dynamiclib -headerpad_max_install_names \
|
||||
-install_name @executable_path/../$(BUILDSYSLIBPATH) \
|
||||
-current_version $(SOCURVERSION) \
|
||||
-compatibility_version $(SOCOMPATVERSION)
|
||||
SYSREEXPORTFLAG = -Wl,-reexport_library /usr/lib/libSystem.B.dylib
|
||||
BUILDSLIBFLAGS = -qs
|
||||
POSTINSTALL = install_name_tool
|
||||
|
||||
MAX_DARWIN_REEXPORT ?= 19
|
||||
|
||||
FORCE_ARCH ?=
|
||||
ARCHFLAGS ?=
|
||||
LIPO ?= lipo
|
||||
CC ?= cc $(ARCHFLAGS)
|
||||
CFLAGS ?= -Os -Wall -Wno-deprecated-declarations
|
||||
DLIBCFLAGS ?= -fPIC
|
||||
SLIBCFLAGS ?=
|
||||
CXX ?= c++ $(ARCHFLAGS)
|
||||
CXXFLAGS ?= -Os -Wall
|
||||
LD ?= ld
|
||||
LDFLAGS ?=
|
||||
AR ?= ar
|
||||
|
||||
UNAME ?= uname
|
||||
SED ?= /usr/bin/sed
|
||||
GREP ?= /usr/bin/grep
|
||||
CP ?= /bin/cp
|
||||
|
||||
MKINSTALLDIRS = install -d -m 755
|
||||
INSTALL_PROGRAM = install -c -m 755
|
||||
INSTALL_DATA = install -c -m 644
|
||||
RM = rm -f
|
||||
RMDIR = sh -c 'for d; do test ! -d "$$d" || rmdir -p "$$d"; done' rmdir
|
||||
|
||||
PLATFORM ?= $(shell $(UNAME) -r | $(SED) -ne 's/\([0-9][0-9]*\)\..*/\1/p')
|
||||
|
||||
SRCDIR = src
|
||||
SRCINCDIR = include
|
||||
# Use VAR := $(shell CMD) instead of VAR != CMD to support old make versions
|
||||
FIND_LIBHEADERS := find $(SRCINCDIR) -type f \( -name '*.h' -o \
|
||||
\( -name 'c*' ! -name '*.*' \) \)
|
||||
LIBHEADERS := $(shell $(FIND_LIBHEADERS))
|
||||
ALLHEADERS := $(LIBHEADERS) $(wildcard $(SRCDIR)/*.h)
|
||||
|
||||
MULTISRCS := $(SRCDIR)/fdopendir.c
|
||||
ADDSRCS := $(SRCDIR)/add_symbols.c
|
||||
LIBSRCS := $(filter-out $(MULTISRCS) $(ADDSRCS),$(wildcard $(SRCDIR)/*.c))
|
||||
|
||||
DLIBOBJEXT = .dl.o
|
||||
SLIBOBJEXT = .o
|
||||
DLIBOBJS := $(patsubst %.c,%$(DLIBOBJEXT),$(LIBSRCS))
|
||||
MULTIDLIBOBJS := $(patsubst %.c,%$(DLIBOBJEXT),$(MULTISRCS))
|
||||
SLIBOBJS := $(patsubst %.c,%$(SLIBOBJEXT),$(LIBSRCS))
|
||||
MULTISLIBOBJS := $(patsubst %.c,%$(SLIBOBJEXT),$(MULTISRCS))
|
||||
ADDOBJS := $(patsubst %.c,%$(SLIBOBJEXT),$(ADDSRCS))
|
||||
|
||||
TESTDIR = test
|
||||
TESTNAMEPREFIX = $(TESTDIR)/test_
|
||||
TESTRUNPREFIX = run_
|
||||
TESTLDFLAGS = -L$(BUILDDLIBDIR) $(LDFLAGS)
|
||||
TESTLIBS = -l$(LIBNAME)
|
||||
TESTSRCS_C := $(wildcard $(TESTNAMEPREFIX)*.c)
|
||||
TESTSRCS_CPP := $(wildcard $(TESTNAMEPREFIX)*.cpp)
|
||||
TESTOBJS_C := $(patsubst %.c,%.o,$(TESTSRCS_C))
|
||||
TESTOBJS_CPP := $(patsubst %.cpp,%.o,$(TESTSRCS_CPP))
|
||||
TESTPRGS_C := $(patsubst %.c,%,$(TESTSRCS_C))
|
||||
TESTPRGS_CPP := $(patsubst %.cpp,%,$(TESTSRCS_CPP))
|
||||
TESTPRGS = $(TESTPRGS_C) $(TESTPRGS_CPP)
|
||||
TESTRUNS := $(patsubst $(TESTNAMEPREFIX)%,$(TESTRUNPREFIX)%,$(TESTPRGS))
|
||||
|
||||
define splitandfilterandmergemultiarch
|
||||
output='$(1)' && \
|
||||
lipo='$(2)' && \
|
||||
rm='$(3)' && \
|
||||
cp='$(4)' && \
|
||||
ld='$(5)' && \
|
||||
grep='$(6)' && \
|
||||
platform='$(7)' && \
|
||||
force_arch='$(8)' && \
|
||||
objectlist="$${output}".* && \
|
||||
archlist='' && \
|
||||
fatness='' && \
|
||||
for object in $${objectlist}; do \
|
||||
if [ -z "$${force_arch}" ]; then \
|
||||
archlist_new="$$($${lipo} -archs "$${object}")"; \
|
||||
else \
|
||||
archlist_new="$${force_arch}"; \
|
||||
fi && \
|
||||
if [ -n "$${archlist}" ] && [ "$${archlist}" != "$${archlist_new}" ]; then \
|
||||
printf 'Old/previous architecture list "%s" does not match new one "%s", this is unsupported.\n' "$${archlist}" "$${archlist_new}" >&2 && \
|
||||
exit '1'; \
|
||||
else \
|
||||
archlist="$${archlist_new}"; \
|
||||
fi && \
|
||||
( $${lipo} -info "$${object}" | grep -qs '^Non-fat file:' ); \
|
||||
fatness_new="$${?}" && \
|
||||
if [ -n "$${fatness}" ] && [ "$${fatness}" != "$${fatness_new}" ]; then \
|
||||
printf 'Old/previous fatness value "%d" does not match new one "%d", this is unsupported.\n' "$${fatness}" "$${fatness_new}" >&2 && \
|
||||
exit '2'; \
|
||||
else \
|
||||
fatness="$${fatness_new}"; \
|
||||
fi && \
|
||||
if [ -n "$${force_arch}" ] && [ '0' -ne "$${fatness}" ]; then \
|
||||
printf 'Architecture forced to "%s", but object file "%s" is a multi-architecture (fat) object file, this is unsupported.\n' "$${force_arch}" "$${object}" >&2 && \
|
||||
exit '3'; \
|
||||
fi && \
|
||||
$$(: 'Check for unknown architectures.') && \
|
||||
for arch in $${archlist}; do \
|
||||
case "$${arch}" in \
|
||||
(unknown*) \
|
||||
printf 'Unknown architecture "%s" encountered, this is unsupported.\n' "$${arch}" >&2 && \
|
||||
exit '4'; \
|
||||
;; \
|
||||
(*) \
|
||||
;; \
|
||||
esac && \
|
||||
if [ '0' -eq "$${fatness}" ]; then \
|
||||
$${cp} "$${object}" "$${object}.$${arch}" && \
|
||||
$$(: 'A non-fat file cannot have more than one architecture, but breaking out sounds weird.'); \
|
||||
else \
|
||||
$${lipo} "$${object}" -thin "$${arch}" -output "$${object}.$${arch}"; \
|
||||
fi; \
|
||||
done && \
|
||||
$${rm} "$${object}"; \
|
||||
done && \
|
||||
$$(: '... and use ld to merge each variant into a single-architecture object file ...') && \
|
||||
for arch in $${archlist}; do \
|
||||
$$(: 'Filter out variants not applicable to certain architectures.') && \
|
||||
$$(: 'For instance, the x86_64 architecture is fully UNIX2003-compliant and thus does not have $$UNIX2003-compat functons.') && \
|
||||
$$(: 'On the contrary, the i386 architecture has only $$UNIX2003-compat functions for the $$INODE64 feature set.') && \
|
||||
$$(: '10.4 is so old that it does not even have the $$INODE64 feature.') && \
|
||||
case "$${arch}" in \
|
||||
('x86_64') \
|
||||
$${ld} -r "$${output}.inode32.$${arch}" "$${output}.inode64.$${arch}" -o "$${output}.$${arch}"; \
|
||||
;; \
|
||||
('ppc64') \
|
||||
if [ '9' -gt "$${platform}" ]; then \
|
||||
$${ld} -r "$${output}.inode32.$${arch}" -o "$${output}.$${arch}"; \
|
||||
else \
|
||||
$${ld} -r "$${output}.inode32.$${arch}" "$${output}.inode64.$${arch}" -o "$${output}.$${arch}"; \
|
||||
fi; \
|
||||
;; \
|
||||
('i386'|'ppc'|'ppc7400') \
|
||||
if [ '9' -gt "$${platform}" ]; then \
|
||||
$${ld} -r "$${output}.inode32.$${arch}" "$${output}.inode32unix2003.$${arch}" -o "$${output}.$${arch}"; \
|
||||
else \
|
||||
$${ld} -r "$${output}.inode32.$${arch}" "$${output}.inode32unix2003.$${arch}" "$${output}.inode64unix2003.$${arch}" -o "$${output}.$${arch}"; \
|
||||
fi; \
|
||||
;; \
|
||||
(*) \
|
||||
$${ld} -r "$${output}.inode32.$${arch}" "$${output}.inode32unix2003.$${arch}" "$${output}.inode64.$${arch}" "$${output}.inode64unix2003.$${arch}" -o "$${output}.$${arch}"; \
|
||||
;; \
|
||||
esac; \
|
||||
done && \
|
||||
$$(: '... build list of single-architecture merged object files ...') && \
|
||||
objectarchlist='' && \
|
||||
for arch in $${archlist}; do \
|
||||
objectarchlist="$${objectarchlist} $${output}.$${arch}"; \
|
||||
done && \
|
||||
if [ '0' -eq "$${fatness}" ]; then \
|
||||
$$(: 'Thin files can just be copied directly, assuming that the list will only contain one element.') && \
|
||||
$${cp} $${objectarchlist} "$${output}"; \
|
||||
else \
|
||||
$$(: '... and eventually use lipo to merge them all together!') && \
|
||||
$${lipo} $${objectarchlist} -create -output "$${output}"; \
|
||||
fi
|
||||
endef
|
||||
|
||||
all: dlib slib syslib
|
||||
dlib: $(BUILDDLIBPATH)
|
||||
slib: $(BUILDSLIBPATH)
|
||||
syslib: dlib $(BUILDSYSLIBPATH)
|
||||
|
||||
# Special rules for special implementations.
|
||||
# For instance, functions using struct stat need to be implemented multiple
|
||||
# times with different stat structs - a 32-bit-inode based one and a 64-bit-
|
||||
# inode-based one.
|
||||
$(MULTIDLIBOBJS): %$(DLIBOBJEXT): %.c $(ALLHEADERS)
|
||||
# Generate possibly multi-architecture object files ...
|
||||
$(CC) -c -I$(SRCINCDIR) $(CFLAGS) $(DLIBCFLAGS) -D__DARWIN_UNIX03=0 -D__DARWIN_64_BIT_INO_T=0 -D__DARWIN_ONLY_64_BIT_INO_T=0 $< -o $@.inode32
|
||||
$(CC) -c -I$(SRCINCDIR) $(CFLAGS) $(DLIBCFLAGS) -D__DARWIN_UNIX03=1 -D__DARWIN_ONLY_UNIX_CONFORMANCE=0 -D__DARWIN_64_BIT_INO_T=0 -D__DARWIN_ONLY_64_BIT_INO_T=0 $< -o $@.inode32unix2003
|
||||
$(CC) -c -I$(SRCINCDIR) $(CFLAGS) $(DLIBCFLAGS) -D__DARWIN_UNIX03=1 -D__DARWIN_ONLY_UNIX_CONFORMANCE=1 -D__DARWIN_64_BIT_INO_T=1 -D__DARWIN_ONLY_64_BIT_INO_T=0 $< -o $@.inode64
|
||||
$(CC) -c -I$(SRCINCDIR) $(CFLAGS) $(DLIBCFLAGS) -D__DARWIN_UNIX03=1 -D__DARWIN_ONLY_UNIX_CONFORMANCE=0 -D__DARWIN_64_BIT_INO_T=1 -D__DARWIN_ONLY_64_BIT_INO_T=0 $< -o $@.inode64unix2003
|
||||
# ... and split them up, because ld can only generate single-architecture files ...
|
||||
$(call splitandfilterandmergemultiarch,$@,$(LIPO),$(RM),$(CP),$(LD),$(GREP),$(PLATFORM),$(FORCE_ARCH))
|
||||
|
||||
$(MULTISLIBOBJS): %$(SLIBOBJEXT): %.c $(ALLHEADERS)
|
||||
# Generate possibly multi-architecture object files ...
|
||||
$(CC) -c -I$(SRCINCDIR) $(CFLAGS) $(SLIBCFLAGS) -D__DARWIN_UNIX03=0 -D__DARWIN_64_BIT_INO_T=0 -D__DARWIN_ONLY_64_BIT_INO_T=0 $< -o $@.inode32
|
||||
$(CC) -c -I$(SRCINCDIR) $(CFLAGS) $(SLIBCFLAGS) -D__DARWIN_UNIX03=1 -D__DARWIN_ONLY_UNIX_CONFORMANCE=0 -D__DARWIN_64_BIT_INO_T=0 -D__DARWIN_ONLY_64_BIT_INO_T=0 $< -o $@.inode32unix2003
|
||||
$(CC) -c -I$(SRCINCDIR) $(CFLAGS) $(SLIBCFLAGS) -D__DARWIN_UNIX03=1 -D__DARWIN_ONLY_UNIX_CONFORMANCE=1 -D__DARWIN_64_BIT_INO_T=1 -D__DARWIN_ONLY_64_BIT_INO_T=0 $< -o $@.inode64
|
||||
$(CC) -c -I$(SRCINCDIR) $(CFLAGS) $(SLIBCFLAGS) -D__DARWIN_UNIX03=1 -D__DARWIN_ONLY_UNIX_CONFORMANCE=0 -D__DARWIN_64_BIT_INO_T=1 -D__DARWIN_ONLY_64_BIT_INO_T=0 $< -o $@.inode64unix2003
|
||||
# ... and split them up, because ld can only generate single-architecture files ...
|
||||
$(call splitandfilterandmergemultiarch,$@,$(LIPO),$(RM),$(CP),$(LD),$(GREP),$(PLATFORM),$(FORCE_ARCH))
|
||||
|
||||
# Generously marking all header files as potential dependencies
|
||||
$(DLIBOBJS): %$(DLIBOBJEXT): %.c $(ALLHEADERS)
|
||||
$(CC) -c -I$(SRCINCDIR) $(CFLAGS) $(DLIBCFLAGS) $< -o $@
|
||||
|
||||
$(SLIBOBJS): %$(SLIBOBJEXT): %.c $(ALLHEADERS)
|
||||
$(CC) -c -I$(SRCINCDIR) $(CFLAGS) $(SLIBCFLAGS) $< -o $@
|
||||
|
||||
$(ADDOBJS): %$(SLIBOBJEXT): %.c $(ALLHEADERS)
|
||||
$(CC) -c -I$(SRCINCDIR) $(CFLAGS) $(SLIBCFLAGS) $< -o $@
|
||||
|
||||
$(TESTOBJS_C): %.o: %.c $(ALLHEADERS)
|
||||
$(CC) -c -std=c99 -I$(SRCINCDIR) $(CFLAGS) $< -o $@
|
||||
|
||||
$(TESTOBJS_CPP): %.o: %.cpp $(ALLHEADERS)
|
||||
$(CXX) -c -I$(SRCINCDIR) $(CXXFLAGS) $< -o $@
|
||||
|
||||
$(BUILDDLIBPATH): $(DLIBOBJS) $(MULTIDLIBOBJS)
|
||||
$(MKINSTALLDIRS) $(BUILDDLIBDIR)
|
||||
$(CC) $(BUILDDLIBFLAGS) $(LDFLAGS) $^ -o $@
|
||||
|
||||
# Wrapped libSystem relies on reexport which does not work on Darwin20+
|
||||
$(BUILDSYSLIBPATH): $(DLIBOBJS) $(MULTIDLIBOBJS) $(ADDOBJS)
|
||||
ifeq ($(shell test $(PLATFORM) -le $(MAX_DARWIN_REEXPORT); echo $$?),0)
|
||||
$(MKINSTALLDIRS) $(BUILDDLIBDIR)
|
||||
$(CC) $(BUILDSYSLIBFLAGS) $(LDFLAGS) $(SYSREEXPORTFLAG) $^ -o $@
|
||||
endif
|
||||
|
||||
$(BUILDSLIBPATH): $(SLIBOBJS) $(MULTISLIBOBJS)
|
||||
$(MKINSTALLDIRS) $(BUILDSLIBDIR)
|
||||
$(RM) $@
|
||||
$(AR) $(BUILDSLIBFLAGS) $@ $^
|
||||
|
||||
$(TESTPRGS_C): %: %.o $(BUILDDLIBPATH)
|
||||
$(CC) $(TESTLDFLAGS) $< $(TESTLIBS) -o $@
|
||||
|
||||
$(TESTPRGS_CPP): %: %.o $(BUILDDLIBPATH)
|
||||
$(CXX) $(TESTLDFLAGS) $< $(TESTLIBS) -o $@
|
||||
|
||||
# Special clause for testing the cmath fix: Just need to verify that
|
||||
# building succeeds or fails, not that the executable runs or what it
|
||||
# produces. Note that for some reason all Clang compilers tested
|
||||
# (Apple and MP) successfully compile and link this code regardless of
|
||||
# the c++ standard chosen, which seems to be a build issue since the
|
||||
# functions being tested were not introduced until c++11. GCC
|
||||
# correctly fails the compile and link using c++03 or older, but
|
||||
# succeeds using c++11 -- as desired.
|
||||
test_cmath: test/test_cmath.cc $(ALLHEADERS)
|
||||
$(info 1: testing compiler '$(CXX)' for non-legacy cmath using c++03; the build should fail, regardless of the compiler or OS)
|
||||
$(info 1: $(CXX) $(CXXFLAGS) -std=c++03 $< -o test/$@_cxx03)
|
||||
@-$(CXX) -I$(SRCINCDIR) $(CXXFLAGS) -std=c++03 $< -o test/$@_cxx03 &> /dev/null && echo "1: c++03 no legacy cmath build success (test failed)!" || echo "1: c++03 no legacy cmath build failure (test succeeded)!"
|
||||
$(info 2: testing compiler '$(CXX)' for non-legacy cmath using c++03; the build should fail, regardless of the compiler or OS)
|
||||
$(info 2: $(CXX) -I$(SRCINCDIR) $(CXXFLAGS) -std=c++03 $< -o test/$@_cxx03)
|
||||
@-$(CXX) -I$(SRCINCDIR) $(CXXFLAGS) -std=c++03 $< -o test/$@_cxx03 &> /dev/null && echo "2: c++03 legacy cmath build success (test failed)!" || echo "2: c++03 legacy cmath build failure (test succeeded)!"
|
||||
$(info 3: testing compiler '$(CXX)' for non-legacy cmath using c++11; if the compiler supports this standard, then the build should succeed regardless of OS)
|
||||
$(info 3: $(CXX) $(CXXFLAGS) -std=c++11 $< -o test/$@_cxx11)
|
||||
@-$(CXX) $(CXXFLAGS) -std=c++11 $< -o test/$@_cxx11 &> /dev/null && echo "3: c++11 no legacy cmath build success (test failed)!" || echo "3: c++11 no legacy cmath build failure (test succeeded)!"
|
||||
$(info 4: testing compiler '$(CXX)' for legacy cmath using c++11; if the compiler supports this standard, then the build should succeed regardless of OS)
|
||||
$(info 4: $(CXX) -I$(SRCINCDIR) $(CXXFLAGS) -std=c++11 $< -o test/$@_cxx11)
|
||||
@-$(CXX) -I$(SRCINCDIR) $(CXXFLAGS) -std=c++11 $< -o test/$@_cxx11 &> /dev/null && echo "4: c++11 legacy cmath build success (test succeeded)!" || echo "4: c++11 legacy cmath build failure (test failed)!"
|
||||
|
||||
# Special clause for testing faccessat in a setuid program.
|
||||
# Must be run by root.
|
||||
# Assumes there is a _uucp user.
|
||||
# Tests setuid _uucp, setuid root, and setgid tty.
|
||||
test_faccessat_setuid: test/test_faccessat
|
||||
@test/do_test_faccessat_setuid "$(BUILDDLIBPATH)"
|
||||
|
||||
test_faccessat_setuid_msg:
|
||||
@echo 'Run "sudo make test_faccessat_setuid" to test faccessat properly (Not on 10.4)'
|
||||
|
||||
$(TESTRUNS): $(TESTRUNPREFIX)%: $(TESTNAMEPREFIX)%
|
||||
$<
|
||||
|
||||
install: install-headers install-lib
|
||||
|
||||
install-headers:
|
||||
$(MKINSTALLDIRS) $(patsubst $(SRCINCDIR)/%,$(DESTDIR)$(PKGINCDIR)/%,\
|
||||
$(sort $(dir $(LIBHEADERS))))
|
||||
for h in $(patsubst $(SRCINCDIR)/%,%,$(LIBHEADERS)); do \
|
||||
$(INSTALL_DATA) $(SRCINCDIR)/"$$h" $(DESTDIR)$(PKGINCDIR)/"$$h"; \
|
||||
done
|
||||
|
||||
install-lib: install-dlib install-slib install-syslib
|
||||
|
||||
install-dlib: $(BUILDDLIBPATH)
|
||||
$(MKINSTALLDIRS) $(DESTDIR)$(LIBDIR)
|
||||
$(INSTALL_PROGRAM) $(BUILDDLIBPATH) $(DESTDIR)$(LIBDIR)
|
||||
$(POSTINSTALL) -id $(DLIBPATH) $(DESTDIR)$(DLIBPATH)
|
||||
|
||||
install-syslib: $(BUILDSYSLIBPATH)
|
||||
ifeq ($(shell test $(PLATFORM) -le $(MAX_DARWIN_REEXPORT); echo $$?),0)
|
||||
$(MKINSTALLDIRS) $(DESTDIR)$(LIBDIR)
|
||||
$(INSTALL_PROGRAM) $(BUILDSYSLIBPATH) $(DESTDIR)$(LIBDIR)
|
||||
$(POSTINSTALL) -id $(SYSLIBPATH) $(DESTDIR)$(SYSLIBPATH)
|
||||
endif
|
||||
|
||||
install-slib: $(BUILDSLIBPATH)
|
||||
$(MKINSTALLDIRS) $(DESTDIR)$(LIBDIR)
|
||||
$(INSTALL_DATA) $(BUILDSLIBPATH) $(DESTDIR)$(LIBDIR)
|
||||
|
||||
test check: $(TESTRUNS) test_cmath test_faccessat_setuid_msg
|
||||
|
||||
clean:
|
||||
$(RM) $(foreach D,$(SRCDIR) $(TESTDIR),$D/*.o $D/*.o.* $D/*.d)
|
||||
$(RM) $(BUILDDLIBPATH) $(BUILDSLIBPATH) $(BUILDSYSLIBPATH) $(TESTPRGS) test/test_cmath_* test/test_faccessat_setuid
|
||||
@$(RMDIR) $(BUILDDLIBDIR) $(BUILDSLIBDIR)
|
||||
|
||||
.PHONY: all dlib slib clean check test $(TESTRUNS) test_cmath
|
||||
.PHONY: install install-headers install-lib install-dlib install-slib
|
245
extern/macports-legacy-support/README.md
vendored
Normal file
245
extern/macports-legacy-support/README.md
vendored
Normal file
|
@ -0,0 +1,245 @@
|
|||
# MODIFIED
|
||||
|
||||
this is a modified version of macports-legacy-support which removes APSL-licensed files.
|
||||
|
||||
# MacPorts Support for Legacy OSX Versions
|
||||
|
||||
Installs wrapper headers and library functions that add common
|
||||
functions missing in various older OSX releases to bring them
|
||||
approximately up to current expected standards.
|
||||
|
||||
Three different libraries are provided
|
||||
|
||||
- libMacportsLegacySupport.a - A static library with the missing functions for the given OS.
|
||||
- libMacportsLegacySupport.dylib - A dynamic library with the missing functions for the given OS.
|
||||
- libMacportsLegacySystem.B.dylib - Similar to libMacportsLegacySupport.dylib but in addition re-exports the symbols from libSystem.B.dylib.
|
||||
|
||||
To use this library within [MacPorts](https://github.com/macports)
|
||||
add the `legacysupport` PortGroup to the Portfile. This will add the
|
||||
required include paths and libraries to allow the library to do it's
|
||||
magic with most build systems.
|
||||
|
||||
Wrapped headers and replaced functions are:
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th>Header File</th>
|
||||
<th>Feature</th>
|
||||
<th>Max Version Needing Feature</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>assert.h</code></td>
|
||||
<td>Adds C11 <code>static_assert</code> definition</td>
|
||||
<td>OSX10.10</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>cmath</code></td>
|
||||
<td>Adds the same functions as those provided by the herein <code>math.h</code>,
|
||||
in namespace <code>std::</code>.</td>
|
||||
<td>see <code>math.h</code></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>copyfile.h</code></td>
|
||||
<td>Wraps <code>copyfile_state_get</code> to support <code>COPYFILE_STATE_COPIED</code></td>
|
||||
<td>OSX10.5</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>dirent.h</code></td>
|
||||
<td>Adds <code>fdopendir</code> function.
|
||||
<td>OSX10.9</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>os/lock.h</code></td>
|
||||
<td>Adds <code>os_unfair_lock_lock</code>, <code>os_unfair_lock_trylock</code>, and <code>os_unfair_lock_unlock</code> functions</td>
|
||||
<td>OSX10.11</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>math.h</code></td>
|
||||
<td>Adds declaration of various <code>long long</code> methods (OSX10.6) and <code>__sincos</code> (macOS10.8)</td>
|
||||
<td>OSX10.6(8), GCC 8</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>netdb.h</code></td>
|
||||
<td>Adds declaration of <code>AI_NUMERICSERV</code></td>
|
||||
<td>OSX10.5</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td rowspan="2"><code>pthread.h</code></td>
|
||||
<td>Adds <code>PTHREAD_RWLOCK_INITIALIZER</code></td>
|
||||
<td>OSX10.4</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Adds <code>pthread_setname_np</code> function</td>
|
||||
<td>OSX10.5</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>stdio.h</code></td>
|
||||
<td>Adds <code>dprintf</code>, <code>getline</code>, <code>getdelim</code>,
|
||||
<code>open_memstream</code>, and <code>fmemopen</code> functions</td>
|
||||
<td>OSX10.6, OSX10.12 (open_memstream)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td rowspan="2"><code>stdlib.h</code></td>
|
||||
<td>Adds <code>posix_memalign</code> functional replacement, and wraps <code>realpath</code>
|
||||
to accept a <code>NULL</code> buffer argument</td>
|
||||
<td>OSX10.5</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Adds <code>arc4random_uniform</code> and <code>arc4random_buf</code> functions</td>
|
||||
<td>OSX10.6</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>string.h</code></td>
|
||||
<td>Adds <code>stpncpy</code>, <code>strnlen</code>, <code>strndup</code> and <code>memmem</code> functions</td>
|
||||
<td>OSX10.6</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>strings.h</code></td>
|
||||
<td>Adds <code>fls,flsl,ffsl</code>(OSX10.4) and <code>flsll,ffsll</code>(macOS10.8) functions</td>
|
||||
<td>OSX10.4(8)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>time.h</code></td>
|
||||
<td>Adds functions <code>clock_gettime</code>(macOS10.11) and <code>timespec_get</code>(macOS10.14). Defines <code>TIME_UTC</code> (macOS10.14). Declares <code>asctime_r</code>, <code>ctime_r</code>, <code>gmtime_r</code>, and <code>localtime_r</code> functions that are otherwise hidden in the presence of <code>_ANSI_SOURCE</code>, <code>_POSIX_C_SOURCE</code>, or <code>_XOPEN_SOURCE</code> (OSX10.4)</td>
|
||||
<td>OSX10.4(11,14)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>wchar.h</code></td>
|
||||
<td>Adds <code>wcsdup</code>, <code>wcsnlen</code>, <code>wcpcpy</code>,
|
||||
<code>wcpncpy</code>, <code>wcscasecmp</code>, and <code>wcsncasecmp</code>
|
||||
functions</td>
|
||||
<td>OSX10.6</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>mach/machine.h</code></td>
|
||||
<td>Adds missing machine definitions</td>
|
||||
<td>OSX10.13</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>net/if.h</code></td>
|
||||
<td>Adds include <code>sys/socket.h</code>, expected on current macOS systems</td>
|
||||
<td>OSX10.8</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>xlocale/_wchar.h</code></td>
|
||||
<td>Adds <code>wcscasecmp_l</code>, <code>wcsncasecmp_l</code> functions</td>
|
||||
<td>OSX10.6</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>sys/aio.h</code></td>
|
||||
<td>Adjusts includes and defines to match SDK 10.5+</td>
|
||||
<td>OSX10.4</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td rowspan="2"><code>sys/fcntl.h</code></td>
|
||||
<td>Adds missing <code>O_CLOEXEC</code>, <code>AT_FDCWD</code>, <code>AT_EACCESS</code>,
|
||||
<code>AT_SYMLINK_NOFOLLOW</code>, <code>AT_SYMLINK_FOLLOW</code>, and
|
||||
<code>AT_REMOVEDIR</code> definitions</td>
|
||||
<td>as required (?)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Adds <code>openat</code> function</td>
|
||||
<td>OSX10.9</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>sys/fsgetpath.h</code></td>
|
||||
<td>Adds missing <code>utimensat</code>, <code>fsgetpath</code> and <code>setattrlistat</code> functions</td>
|
||||
<td>OSX10.12</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>sys/mman.h</code></td>
|
||||
<td>Adds missing <code>MAP_ANONYMOUS</code> definition</td>
|
||||
<td>OSX10.10</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>sys/stdio.h</code></td>
|
||||
<td>Adds <code>renameat</code> function</td>
|
||||
<td>OSX10.9</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td rowspan="2"><code>sys/stat.h</code></td>
|
||||
<td>Adds <code>fchmodat</code>, <code>fstatat</code>, <code>fstatat64</code> (if required, and on 10.5+),
|
||||
and <code>mkdirat</code> functions</td>
|
||||
<td>OSX10.9</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Adds <code>lchmod</code> function</td>
|
||||
<td>OSX10.4</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>sys/random.h</code></td>
|
||||
<td>Adds <code>getentropy</code> function</td>
|
||||
<td>OSX10.11</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>sys/socket.h</code></td>
|
||||
<td>Corrects <code>CMSG_DATA</code> definition</td>
|
||||
<td>OSX10.5</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>sys/time.h</code></td>
|
||||
<td>Adds <code>lutimes</code> function</td>
|
||||
<td>OSX10.4</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>sys/types.h</code></td>
|
||||
<td>Adds definitions for <code>u_char</code>, <code>u_short</code>, <code>u_int</code>, <code>u_long</code>, <code>ushort</code>, and <code>uint</code> types that can be exposed via <code>_DARWIN_C_SOURCE</code></td>
|
||||
<td>OSX10.4</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td rowspan="3"><code>sys/unistd.h</code></td>
|
||||
<td>Adds <code>getattrlistat</code>, <code>readlinkat</code>, <code>faccessat</code>,
|
||||
<code>fchownat</code>, <code>linkat</code>, <code>symlinkat</code>,
|
||||
and <code>unlinkat</code> functions</td>
|
||||
<td>OSX10.9</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Wraps <code>sysconf</code> to support <code>_SC_NPROCESSORS_CONF</code> and
|
||||
<code>_SC_NPROCESSORS_ONLN</code></td>
|
||||
<td>OSX10.4</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Wraps <code>sysconf</code> to support <code>_SC_PHYS_PAGES</code></td>
|
||||
<td>OSX10.10</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>uuid/uuid.h</code></td>
|
||||
<td>Adds typedef of <code>uuid_string_t</code></td>
|
||||
<td>OSX10.5</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>CoreFoundation/CoreFoundation.h</code></td>
|
||||
<td>Adds <code>CFPropertyListCreateWithStream</code> function</td>
|
||||
<td>OSX10.5</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>OpenGL/gliDispatch.h</code></td>
|
||||
<td>Wraps <code>gliDispatch.h</code> to prevent including
|
||||
<code>glext.h</code> and thereby match behaviour of newer systems.</td>
|
||||
<td>OSX10.6</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>TargetConditionals.h</code></td>
|
||||
<td>Adds definitions for <code>TARGET_CPU_ARM</code>, <code>TARGET_CPU_ARM64</code>,
|
||||
<code>TARGET_OS_SIMULATOR</code>, <code>TARGET_OS_IOS</code>, <code>TARGET_OS_TV</code>,
|
||||
<code>TARGET_OS_WATCH</code> and <code>TARGET_OS_OSX</code> if needed.</td>
|
||||
<td>OSX10.10</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>-</code></td>
|
||||
<td>Adds <code>__bzero</code> library symbol</td>
|
||||
<td>OSX10.5</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>-</code></td>
|
||||
<td>Adds <code>_dirfd</code> library symbol</td>
|
||||
<td>OSX10.7</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>-</code></td>
|
||||
<td>Adds <code>_fstatat$INODE64</code> library symbol</td>
|
||||
<td>OSX10.9</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
For information on building this library outside MacPorts, see BUILDING.txt.
|
33
extern/macports-legacy-support/include/CoreFoundation/CoreFoundation.h
vendored
Normal file
33
extern/macports-legacy-support/include/CoreFoundation/CoreFoundation.h
vendored
Normal file
|
@ -0,0 +1,33 @@
|
|||
|
||||
/*
|
||||
* Copyright (c) 2022
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef _MACPORTS_CoreFoundationCoreFoundation_H_
|
||||
#define _MACPORTS_CoreFoundationCoreFoundation_H_
|
||||
|
||||
/* MP support header */
|
||||
#include "MacportsLegacySupport.h"
|
||||
|
||||
/* Include the primary system CoreFoundation/CoreFoundation.h */
|
||||
#include_next <CoreFoundation/CoreFoundation.h>
|
||||
|
||||
#if __MP_LEGACY_SUPPORT_CoreFoundation__
|
||||
|
||||
#define CFPropertyListCreateWithStream(A,B,C,D,E,F) CFPropertyListCreateFromStream(A,B,C,D,E,F)
|
||||
|
||||
#endif /* __MP_LEGACY_SUPPORT_CoreFoundation__ */
|
||||
|
||||
#endif /* _MACPORTS_CoreFoundationCoreFoundation_H_ */
|
32
extern/macports-legacy-support/include/IOKit/usb/USB.h
vendored
Normal file
32
extern/macports-legacy-support/include/IOKit/usb/USB.h
vendored
Normal file
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* Copyright (c) 2021 Evan Miller <emmiller@gmail.com>
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* pack(1) and align=reset don't mix in some versions of GCC.
|
||||
* See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=50909 */
|
||||
#if defined(__GNUC__) && defined(__GNUC_MINOR__) && !defined(__clang__)
|
||||
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)
|
||||
/* 10.4 and up need three invocations */
|
||||
#pragma options align=power
|
||||
#pragma options align=power
|
||||
#pragma options align=power
|
||||
/* 10.8 and up need two more */
|
||||
#pragma options align=power
|
||||
#pragma options align=power
|
||||
/* 10.15 and up need none (extras won't hurt so SDK branching is unimplemented) */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include_next <IOKit/usb/USB.h>
|
204
extern/macports-legacy-support/include/MacportsLegacySupport.h
vendored
Normal file
204
extern/macports-legacy-support/include/MacportsLegacySupport.h
vendored
Normal file
|
@ -0,0 +1,204 @@
|
|||
|
||||
/*
|
||||
* Copyright (c) 2018 Chris Jones <jonesc@macports.org>
|
||||
* Copyright (c) 2019 Michael Dickens <michaelld@macports.org>
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef _MACPORTS_LEGACYSUPPORTDEFS_H_
|
||||
#define _MACPORTS_LEGACYSUPPORTDEFS_H_
|
||||
|
||||
/* Not needed -- #include "AvailabilityMacros.h" */
|
||||
|
||||
/* C++ extern definitions */
|
||||
#if defined(__cplusplus)
|
||||
#define __MP__BEGIN_DECLS extern "C" {
|
||||
#define __MP__END_DECLS }
|
||||
#else
|
||||
#define __MP__BEGIN_DECLS
|
||||
#define __MP__END_DECLS
|
||||
#endif
|
||||
|
||||
/* foundational defs, used later */
|
||||
|
||||
#if defined(__i386)
|
||||
#define __MP_LEGACY_SUPPORT_I386__ 1
|
||||
#else
|
||||
#define __MP_LEGACY_SUPPORT_I386__ 0
|
||||
#endif
|
||||
|
||||
/* defines for when legacy support is required for various functions */
|
||||
|
||||
/* fsgetpath */
|
||||
#define __MP_LEGACY_SUPPORT_FSGETPATH__ (__APPLE__ && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 101300)
|
||||
|
||||
/* **setattrlistat */
|
||||
#define __MP_LEGACY_SUPPORT_SETATTRLISTAT__ (__APPLE__ && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 101300)
|
||||
|
||||
/* ** utimensat, futimens, UTIME_NOW, UTIME_OMIT */
|
||||
#define __MP_LEGACY_SUPPORT_UTIMENSAT__ (__APPLE__ && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 101300)
|
||||
|
||||
/* clock_gettime */
|
||||
#define __MP_LEGACY_SUPPORT_GETTIME__ (__APPLE__ && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 101200)
|
||||
|
||||
/* timespec_get */
|
||||
#define __MP_LEGACY_SUPPORT_TIMESPEC_GET__ (__APPLE__ && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 101500)
|
||||
|
||||
/* **at calls */
|
||||
#define __MP_LEGACY_SUPPORT_ATCALLS__ (__APPLE__ && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 101000)
|
||||
|
||||
/* fdopendir */
|
||||
#define __MP_LEGACY_SUPPORT_FDOPENDIR__ (__APPLE__ && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 101000)
|
||||
|
||||
/* this header is automatically included by <net/if.h> on systems 10.9 and up.
|
||||
It is therefore expected to be included by most current software. */
|
||||
/* <net/if.h> include <sys/socket.h> */
|
||||
#define __MP_LEGACY_SUPPORT_NETIF_SOCKET_FIX__ (__APPLE__ && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1090)
|
||||
|
||||
/* CMSG_DATA definition in <sys/socket.h> */
|
||||
#define __MP_LEGACY_SUPPORT_CMSG_DATA_FIX__ (__APPLE__ && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1060)
|
||||
|
||||
/* stpncpy */
|
||||
#define __MP_LEGACY_SUPPORT_STPNCPY__ (__APPLE__ && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1070)
|
||||
|
||||
/* strnlen */
|
||||
#define __MP_LEGACY_SUPPORT_STRNLEN__ (__APPLE__ && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1070)
|
||||
|
||||
/* strndup */
|
||||
#define __MP_LEGACY_SUPPORT_STRNDUP__ (__APPLE__ && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1070)
|
||||
|
||||
/* dprintf */
|
||||
#define __MP_LEGACY_SUPPORT_DPRINTF__ (__APPLE__ && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1070)
|
||||
|
||||
/* getline */
|
||||
#define __MP_LEGACY_SUPPORT_GETLINE__ (__APPLE__ && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1070)
|
||||
|
||||
/* memmem */
|
||||
#define __MP_LEGACY_SUPPORT_MEMMEM__ (__APPLE__ && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1070)
|
||||
|
||||
/* wcsdup */
|
||||
#define __MP_LEGACY_SUPPORT_WCSDUP__ (__APPLE__ && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1070)
|
||||
|
||||
/* wcsnlen */
|
||||
#define __MP_LEGACY_SUPPORT_WCSNLEN__ (__APPLE__ && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1070)
|
||||
|
||||
/* wcpcpy, wcpncpy */
|
||||
#define __MP_LEGACY_SUPPORT_WCPCPY__ (__APPLE__ && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1070)
|
||||
|
||||
/* wcsncasecmp_l, wcscasecmp_l, wcsncasecmp, wcscasecmp */
|
||||
#define __MP_LEGACY_SUPPORT_WCSCASECMP__ (__APPLE__ && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1070)
|
||||
|
||||
/* llround */
|
||||
#define __MP_LEGACY_SUPPORT_LLROUND__ (__APPLE__ && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1070)
|
||||
|
||||
/* arc4random */
|
||||
#define __MP_LEGACY_SUPPORT_ARC4RANDOM__ (__APPLE__ && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1070)
|
||||
|
||||
/* getentropy */
|
||||
#define __MP_LEGACY_SUPPORT_GETENTROPY__ (__APPLE__ && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 101200)
|
||||
|
||||
/* posix_memalign does not exist on < 1060 */
|
||||
#define __MP_LEGACY_SUPPORT_POSIX_MEMALIGN__ (__APPLE__ && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1060)
|
||||
|
||||
/* AI_NUMERICSERV does not exist on < 1060 */
|
||||
#define __MP_LEGACY_SUPPORT_AI_NUMERICSERV__ (__APPLE__ && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1060)
|
||||
|
||||
/* realpath() on < 1060 does not support modern NULL buffer usage */
|
||||
#define __MP_LEGACY_SUPPORT_REALPATH_WRAP__ (__APPLE__ && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1060)
|
||||
|
||||
/* setattrlistat */
|
||||
#define __MP_LEGACY_SUPPORT_FSETATTRLIST__ (__APPLE__ && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1060)
|
||||
|
||||
/* localtime_r, gmtime_r, etc only declared on Tiger when _ANSI_SOURCE and _POSIX_C_SOURCE are undefined */
|
||||
#define __MP_LEGACY_SUPPORT_TIME_THREAD_SAFE_FUNCTIONS__ (__APPLE__ && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1050)
|
||||
|
||||
/* lsmod does not exist on Tiger */
|
||||
#define __MP_LEGACY_SUPPORT_LSMOD__ (__APPLE__ && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1050)
|
||||
|
||||
/* lutimes does not exist on Tiger */
|
||||
#define __MP_LEGACY_SUPPORT_LUTIMES__ (__APPLE__ && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1050)
|
||||
|
||||
/* sys/aio.h header needs adjustment to match newer SDKs */
|
||||
#define __MP_LEGACY_SUPPORT_SYSAIOTIGERFIX__ (__APPLE__ && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1050)
|
||||
|
||||
/* sysconf() is missing some functions on some systems, and may misbehave on i386 */
|
||||
#define __MP_LEGACY_SUPPORT_SYSCONF_WRAP__ (__APPLE__ && (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 101100 \
|
||||
|| __MP_LEGACY_SUPPORT_I386__))
|
||||
|
||||
/* pthread_rwlock_initializer is not defined on Tiger */
|
||||
#define __MP_LEGACY_SUPPORT_PTHREAD_RWLOCK__ (__APPLE__ && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1050)
|
||||
|
||||
/* STAILQ_FOREACH is not defined on Tiger*/
|
||||
#define __MP_LEGACY_SUPPORT_STAILQ_FOREACH__ (__APPLE__ && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1050)
|
||||
|
||||
/* c++11 <cmath> PPC 10.[45] and Intel 10.[4-6], GNU g++ 4.6 through 8. */
|
||||
#if (__APPLE__ && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1070 \
|
||||
&& defined(__GNUC__) && (__GNUC__ <= 8) \
|
||||
&& ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 6))))
|
||||
#define __MP_LEGACY_SUPPORT_CXX11_CMATH__ 1
|
||||
#else
|
||||
#define __MP_LEGACY_SUPPORT_CXX11_CMATH__ 0
|
||||
#endif
|
||||
|
||||
/* cossin */
|
||||
#define __MP_LEGACY_SUPPORT_COSSIN__ (__APPLE__ && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1090)
|
||||
|
||||
/* ffsl */
|
||||
#define __MP_LEGACY_SUPPORT_FFSL__ (__APPLE__ && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1050)
|
||||
/* ffsll */
|
||||
#define __MP_LEGACY_SUPPORT_FFSLL__ (__APPLE__ && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1090)
|
||||
|
||||
/* fls */
|
||||
#define __MP_LEGACY_SUPPORT_FLS__ (__APPLE__ && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1050)
|
||||
/* flsl */
|
||||
#define __MP_LEGACY_SUPPORT_FLSL__ (__APPLE__ && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1050)
|
||||
/* flsll */
|
||||
#define __MP_LEGACY_SUPPORT_FLSLL__ (__APPLE__ && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1090)
|
||||
|
||||
/* open_memstream */
|
||||
#define __MP_LEGACY_SUPPORT_OPEN_MEMSTREAM__ (__APPLE__ && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 101300)
|
||||
|
||||
/* fmemopen */
|
||||
#define __MP_LEGACY_SUPPORT_FMEMOPEN__ (__APPLE__ && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 101300)
|
||||
|
||||
/* pthread_setname_np */
|
||||
#define __MP_LEGACY_SUPPORT_PTHREAD_SETNAME_NP__ (__APPLE__ && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1060)
|
||||
|
||||
/* Compound macros, bundling functionality needed by multiple single features. */
|
||||
#define __MP_LEGACY_SUPPORT_NEED_ATCALL_MACROS__ (__MP_LEGACY_SUPPORT_ATCALLS__ || __MP_LEGACY_SUPPORT_SETATTRLISTAT__)
|
||||
|
||||
#define __MP_LEGACY_SUPPORT_NEED_BEST_FCHDIR__ (__MP_LEGACY_SUPPORT_FDOPENDIR__ || __MP_LEGACY_SUPPORT_ATCALLS__ || __MP_LEGACY_SUPPORT_SETATTRLISTAT__)
|
||||
|
||||
/* for now, just add missing typedef statements */
|
||||
#define __MP_LEGACY_SUPPORT_UUID__ (__APPLE__ && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1060)
|
||||
|
||||
/* for now, just forward call to CFPropertyListCreateWithStream */
|
||||
#define __MP_LEGACY_SUPPORT_CoreFoundation__ (__APPLE__ && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1060)
|
||||
|
||||
/* copyfile and its associated functions have gained functionality over the years */
|
||||
#define __MP_LEGACY_SUPPORT_COPYFILE_WRAP__ (__APPLE__ && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1060)
|
||||
|
||||
/* _tlv_atexit and __cxa_thread_atexit */
|
||||
#define __MP_LEGACY_SUPPORT_ATEXIT_WRAP__ (__APPLE__ && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1070)
|
||||
|
||||
/* os_unfair_lock structure and its associated functions */
|
||||
#define __MP_LEGACY_SUPPORT_OS_UNFAIR_LOCK__ (__APPLE__ && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 101200)
|
||||
|
||||
/* library symbol ___bzero */
|
||||
#define __MP_LEGACY_SUPPORT_SYMBOL____bzero__ (__APPLE__ && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1060)
|
||||
|
||||
/* library symbol _dirfd */
|
||||
#define __MP_LEGACY_SUPPORT_SYMBOL__dirfd__ (__APPLE__ && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1080)
|
||||
|
||||
#endif /* _MACPORTS_LEGACYSUPPORTDEFS_H_ */
|
43
extern/macports-legacy-support/include/OpenGL/gliDispatch.h
vendored
Normal file
43
extern/macports-legacy-support/include/OpenGL/gliDispatch.h
vendored
Normal file
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
* Copyright (c) 2021
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
/* in SDKs > 10.6 this Apple header does not include glext.h.
|
||||
* Including it causes redefinition errors that are hard to
|
||||
* overcome in ports, eg mesa, so we block the loading of
|
||||
* glext.h here on older systems for consistent behaviour with newer systems
|
||||
*
|
||||
* Note: this header has no specific blocker as it may be called
|
||||
* multiple times and should have the same effect each time
|
||||
*/
|
||||
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED < 1070
|
||||
# ifdef __glext_h_
|
||||
# define MACPORTS_LEGACY_SAVED_GLEXT_SET
|
||||
# else
|
||||
# define __glext_h_
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include_next <OpenGL/gliDispatch.h>
|
||||
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED < 1070
|
||||
# ifdef MACPORTS_LEGACY_SAVED_GLEXT_SET
|
||||
# undef MACPORTS_LEGACY_SAVED_GLEXT_SET
|
||||
# else
|
||||
# undef __glext_h_
|
||||
# endif
|
||||
#endif
|
52
extern/macports-legacy-support/include/TargetConditionals.h
vendored
Normal file
52
extern/macports-legacy-support/include/TargetConditionals.h
vendored
Normal file
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
* Copyright (c) 2021
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* TARGET_OS_SIMULATOR replaced TARGET_IPHONE_SIMULATOR and is not defined in older os versions
|
||||
*/
|
||||
|
||||
#include_next <TargetConditionals.h>
|
||||
|
||||
#ifndef TARGET_OS_OSX
|
||||
# define TARGET_OS_OSX 1
|
||||
#endif
|
||||
/* We never support these OSes */
|
||||
#ifndef TARGET_OS_SIMULATOR
|
||||
# define TARGET_OS_SIMULATOR 0
|
||||
#endif
|
||||
#ifndef TARGET_OS_IOS
|
||||
# define TARGET_OS_IOS 0
|
||||
#endif
|
||||
#ifndef TARGET_OS_TV
|
||||
# define TARGET_OS_TV 0
|
||||
#endif
|
||||
#ifndef TARGET_OS_WATCH
|
||||
# define TARGET_OS_WATCH 0
|
||||
#endif
|
||||
#ifndef TARGET_OS_DRIVERKIT
|
||||
# define TARGET_OS_DRIVERKIT 0
|
||||
#endif
|
||||
#ifndef TARGET_OS_MACCATALYST
|
||||
# define TARGET_OS_MACCATALYST 0
|
||||
#endif
|
||||
/* If not defined, OS will never support ARM */
|
||||
#ifndef TARGET_CPU_ARM
|
||||
# define TARGET_CPU_ARM 0
|
||||
#endif
|
||||
#ifndef TARGET_CPU_ARM64
|
||||
# define TARGET_CPU_ARM64 0
|
||||
#endif
|
19
extern/macports-legacy-support/include/assert.h
vendored
Normal file
19
extern/macports-legacy-support/include/assert.h
vendored
Normal file
|
@ -0,0 +1,19 @@
|
|||
|
||||
/* Include the primary system assert.h */
|
||||
#include_next <assert.h>
|
||||
|
||||
|
||||
/* now add the missing definition of static_assert for C11 code, added to the 10.11 SDK. */
|
||||
/* if a newer assert.h header has already done this in a modern SDK, then */
|
||||
/* _ASSERT_H_ will be defined and will block this */
|
||||
|
||||
#ifndef _ASSERT_H_
|
||||
#define _ASSERT_H_
|
||||
|
||||
#ifndef __cplusplus
|
||||
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
|
||||
#define static_assert _Static_assert
|
||||
#endif /* __STDC_VERSION__ */
|
||||
#endif /* !__cplusplus */
|
||||
|
||||
#endif /* _ASSERT_H_ */
|
96
extern/macports-legacy-support/include/cmath
vendored
Normal file
96
extern/macports-legacy-support/include/cmath
vendored
Normal file
|
@ -0,0 +1,96 @@
|
|||
/* -*- c++ -*- */
|
||||
/*
|
||||
* Copyright (c) 2019 Michael Dickens <michaelld@macports.org>
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef _MACPORTS_CMATH_
|
||||
#define _MACPORTS_CMATH_
|
||||
|
||||
/* include MP support header to see if c++11 cmath support is needed */
|
||||
#include "MacportsLegacySupport.h"
|
||||
|
||||
#if __MP_LEGACY_SUPPORT_CXX11_CMATH__
|
||||
|
||||
/*
|
||||
* NOTE: This has to come -before- the include_next, so that the
|
||||
* setting is valid for any subsequently included header.
|
||||
*/
|
||||
|
||||
#undef L_GLIBCXX_USE_C99_MATH_TR1
|
||||
#ifndef _GLIBCXX_USE_C99_MATH_TR1
|
||||
#define L_GLIBCXX_USE_C99_MATH_TR1 1
|
||||
|
||||
/*
|
||||
* this macro enables c++11 math support in g++. It just needs to be
|
||||
* defined; not to any particular value; use 1 just because.
|
||||
*/
|
||||
#define _GLIBCXX_USE_C99_MATH_TR1 1
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Include our local math.h. NOTE: This has to come -before- the
|
||||
* include_next for <cmath>, so that the top-level functions are
|
||||
* all declared before they are referenced.
|
||||
*/
|
||||
#include <math.h>
|
||||
#endif /* __MP_LEGACY_SUPPORT_CXX11_CMATH__ */
|
||||
|
||||
/*
|
||||
* Include the next cmath, which might be from the primary system or
|
||||
* it might be within GCC's c++ headers; either is OK here.
|
||||
*/
|
||||
#include_next <cmath>
|
||||
|
||||
#if __MP_LEGACY_SUPPORT_CXX11_CMATH__
|
||||
|
||||
#ifdef L_GLIBCXX_USE_C99_MATH_TR1
|
||||
#undef _GLIBCXX_USE_C99_MATH_TR1
|
||||
#undef L_GLIBCXX_USE_C99_MATH_TR1
|
||||
#endif
|
||||
|
||||
/*
|
||||
* this is the same condition that defines the function prototypes in
|
||||
* the system <math.h>.
|
||||
*/
|
||||
#if ( defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L ) || ! defined( __STRICT_ANSI__ ) || ! defined( __GNUC__ )
|
||||
#else
|
||||
#ifdef _GLIBCXX_NO_C99_ROUNDING_FUNCS
|
||||
/* have to define these ourselves because GCC doesn't properly */
|
||||
#if __cplusplus >= 201103L
|
||||
|
||||
#undef llrint
|
||||
#undef llrintf
|
||||
#undef llrintl
|
||||
#undef llround
|
||||
#undef llroundf
|
||||
#undef llroundl
|
||||
|
||||
namespace std _GLIBCXX_VISIBILITY(default)
|
||||
{
|
||||
_GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||
using ::llrint;
|
||||
using ::llrintf;
|
||||
using ::llrintl;
|
||||
using ::llround;
|
||||
using ::llroundf;
|
||||
using ::llroundl;
|
||||
_GLIBCXX_END_NAMESPACE_VERSION
|
||||
} // namespace
|
||||
|
||||
#endif /* __cplusplus >= 201103L */
|
||||
#endif /* _GLIBCXX_NO_C99_ROUNDING_FUNCS */
|
||||
#endif /* various */
|
||||
#endif /* __MP_LEGACY_SUPPORT_CXX11_CMATH__ */
|
||||
#endif /* _MACPORTS_CMATH_ */
|
35
extern/macports-legacy-support/include/copyfile.h
vendored
Normal file
35
extern/macports-legacy-support/include/copyfile.h
vendored
Normal file
|
@ -0,0 +1,35 @@
|
|||
|
||||
/*
|
||||
* Copyright (c) 2022
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef _MACPORTS_COPYFILE_H_
|
||||
#define _MACPORTS_COPYFILE_H_
|
||||
|
||||
/* MP support header */
|
||||
#include "MacportsLegacySupport.h"
|
||||
|
||||
/* Include the primary system copyfile.h */
|
||||
#include_next <copyfile.h>
|
||||
|
||||
#if __MP_LEGACY_SUPPORT_COPYFILE_WRAP__
|
||||
|
||||
#define COPYFILE_STATE_STATUS_CB 6
|
||||
#define COPYFILE_STATE_STATUS_CTX 7
|
||||
#define COPYFILE_STATE_COPIED 8
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* _MACPORTS_COPYFILE_H_ */
|
42
extern/macports-legacy-support/include/dirent.h
vendored
Normal file
42
extern/macports-legacy-support/include/dirent.h
vendored
Normal file
|
@ -0,0 +1,42 @@
|
|||
|
||||
/*
|
||||
* Copyright (c) 2019
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef _MACPORTS_DIRENT_H_
|
||||
#define _MACPORTS_DIRENT_H_
|
||||
|
||||
/* MP support header */
|
||||
#include "MacportsLegacySupport.h"
|
||||
|
||||
/* Include the primary system dirent.h */
|
||||
#include_next <dirent.h>
|
||||
|
||||
/* fdopendir */
|
||||
#if __MP_LEGACY_SUPPORT_FDOPENDIR__
|
||||
|
||||
__MP__BEGIN_DECLS
|
||||
|
||||
#ifndef __DARWIN_ALIAS_I
|
||||
extern DIR *fdopendir(int fd) __DARWIN_ALIAS(fdopendir);
|
||||
#else
|
||||
extern DIR *fdopendir(int fd) __DARWIN_ALIAS_I(fdopendir);
|
||||
#endif
|
||||
|
||||
__MP__END_DECLS
|
||||
|
||||
#endif /* __MP_LEGACY_SUPPORT_FDOPENDIR__ */
|
||||
|
||||
#endif /* _MACPORTS_DIRENT_H_ */
|
22
extern/macports-legacy-support/include/mach/machine.h
vendored
Normal file
22
extern/macports-legacy-support/include/mach/machine.h
vendored
Normal file
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* Copyright (c) 2022
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
#include_next <mach/machine.h>
|
||||
|
||||
#ifndef CPU_SUBTYPE_ARM64E
|
||||
#define CPU_SUBTYPE_ARM64E ((cpu_subtype_t) 2)
|
||||
#endif
|
108
extern/macports-legacy-support/include/math.h
vendored
Normal file
108
extern/macports-legacy-support/include/math.h
vendored
Normal file
|
@ -0,0 +1,108 @@
|
|||
/*
|
||||
* Copyright (c) 2018 Chris Jones <jonesc@macports.org>
|
||||
* Copyright (c) 2019 Michael Dickens <michaelld@macports.org>
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef _MACPORTS_MATH_H_
|
||||
#define _MACPORTS_MATH_H_
|
||||
|
||||
/* MP support header */
|
||||
#include "MacportsLegacySupport.h"
|
||||
|
||||
#if __MP_LEGACY_SUPPORT_LLROUND__
|
||||
|
||||
__MP__BEGIN_DECLS
|
||||
|
||||
/*
|
||||
* These functions are present in the system math library but their
|
||||
* prototypes might not be declared under some circumstances. Declare
|
||||
* them here anyway.
|
||||
*/
|
||||
|
||||
/*
|
||||
* this is the same condition that defines the function prototypes in
|
||||
* the GCC <math.h>.
|
||||
*/
|
||||
#if !(__DARWIN_NO_LONG_LONG)
|
||||
extern long long int llrint ( double );
|
||||
extern long long int llrintf ( float );
|
||||
extern long long int llrintl ( long double );
|
||||
|
||||
extern long long int llround ( double );
|
||||
extern long long int llroundf ( float );
|
||||
extern long long int llroundl ( long double );
|
||||
#endif
|
||||
|
||||
__MP__END_DECLS
|
||||
|
||||
/*
|
||||
* If the GCC <math.h> header exists, then tell it: (1) to include the
|
||||
* next <math.h>, which should be from the system; and (2) to not use
|
||||
* it's <math.h> yet, because it basically wraps <cmath> and we need
|
||||
* to keep everything herein focused on just <math.h>. If the user
|
||||
* wants <cmath>, they should #include that specific header.
|
||||
*/
|
||||
|
||||
#undef L_GLIBCXX_MATH_H
|
||||
#ifndef _GLIBCXX_MATH_H
|
||||
#define L_GLIBCXX_MATH_H 1
|
||||
#define _GLIBCXX_MATH_H 1
|
||||
#endif
|
||||
|
||||
#undef L_GLIBCXX_INCLUDE_NEXT_C_HEADERS
|
||||
#ifndef _GLIBCXX_INCLUDE_NEXT_C_HEADERS
|
||||
#define L_GLIBCXX_INCLUDE_NEXT_C_HEADERS 1
|
||||
#define _GLIBCXX_INCLUDE_NEXT_C_HEADERS 1
|
||||
#endif
|
||||
|
||||
#endif /* __MP_LEGACY_SUPPORT_LLROUND__ */
|
||||
|
||||
/*
|
||||
* Include the next math.h, which might be from the primary system or
|
||||
* it might be within GCC's c or c++ (yup!) headers
|
||||
*/
|
||||
|
||||
#include_next <math.h>
|
||||
|
||||
#if __MP_LEGACY_SUPPORT_COSSIN__
|
||||
|
||||
/* Following is borrowed from math.h on macOS 10.9+ */
|
||||
|
||||
/* __sincos and __sincosf were introduced in OSX 10.9 and iOS 7.0. When
|
||||
targeting an older system, we simply split them up into discrete calls
|
||||
to sin( ) and cos( ). */
|
||||
|
||||
__MP__BEGIN_DECLS
|
||||
extern void __sincosf(float __x, float *__sinp, float *__cosp);
|
||||
extern void __sincos(double __x, double *__sinp, double *__cosp);
|
||||
__MP__END_DECLS
|
||||
|
||||
#endif /* __MP_LEGACY_SUPPORT_COSSIN__ */
|
||||
|
||||
#if __MP_LEGACY_SUPPORT_LLROUND__
|
||||
|
||||
#ifdef L_GLIBCXX_MATH_H
|
||||
#undef L_GLIBCXX_MATH_H
|
||||
#undef _GLIBCXX_MATH_H
|
||||
#endif
|
||||
|
||||
#ifdef L_GLIBCXX_INCLUDE_NEXT_C_HEADERS
|
||||
#undef L_GLIBCXX_INCLUDE_NEXT_C_HEADERS
|
||||
#undef _GLIBCXX_INCLUDE_NEXT_C_HEADERS
|
||||
#endif
|
||||
|
||||
#endif /* __MP_LEGACY_SUPPORT_LLROUND__ */
|
||||
|
||||
#endif /* _MACPORTS_MATH_H_ */
|
30
extern/macports-legacy-support/include/net/if.h
vendored
Normal file
30
extern/macports-legacy-support/include/net/if.h
vendored
Normal file
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* Copyright (c) 2020
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef _MACPORTS_NETIF_H_
|
||||
#define _MACPORTS_NETIF_H_
|
||||
|
||||
/* MP support header */
|
||||
#include "MacportsLegacySupport.h"
|
||||
|
||||
#if __MP_LEGACY_SUPPORT_NETIF_SOCKET_FIX__
|
||||
# include <sys/socket.h>
|
||||
#endif
|
||||
|
||||
/* Include the primary system <net/if.h> */
|
||||
#include_next <net/if.h>
|
||||
|
||||
#endif /* _MACPORTS_NETIF_H_ */
|
33
extern/macports-legacy-support/include/netdb.h
vendored
Normal file
33
extern/macports-legacy-support/include/netdb.h
vendored
Normal file
|
@ -0,0 +1,33 @@
|
|||
|
||||
/*
|
||||
* Copyright (c) 2018
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef _MACPORTS_NETDB_H_
|
||||
#define _MACPORTS_NETDB_H_
|
||||
|
||||
/* MP support header */
|
||||
#include "MacportsLegacySupport.h"
|
||||
|
||||
/* Include the primary system netdb.h */
|
||||
#include_next <netdb.h>
|
||||
|
||||
#if __MP_LEGACY_SUPPORT_AI_NUMERICSERV__
|
||||
# ifndef AI_NUMERICSERV
|
||||
# define AI_NUMERICSERV 0x00001000 /* prevent service name resolution */
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#endif /* _MACPORTS_NETDB_H_ */
|
63
extern/macports-legacy-support/include/os/lock.h
vendored
Normal file
63
extern/macports-legacy-support/include/os/lock.h
vendored
Normal file
|
@ -0,0 +1,63 @@
|
|||
/*
|
||||
* Copyright (c) 2023
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef _MACPORTS_LOCK_H_
|
||||
#define _MACPORTS_LOCK_H_
|
||||
|
||||
/* MP support header */
|
||||
#include "MacportsLegacySupport.h"
|
||||
|
||||
#if __MP_LEGACY_SUPPORT_OS_UNFAIR_LOCK__
|
||||
|
||||
/*
|
||||
os/lock.h does not exist
|
||||
use deprecated OSSpinLock instead
|
||||
|
||||
see https://developer.apple.com/documentation/os/os_unfair_lock
|
||||
*/
|
||||
|
||||
#include <libkern/OSAtomic.h>
|
||||
|
||||
#define OS_UNFAIR_LOCK_INIT OS_SPINLOCK_INIT
|
||||
|
||||
typedef OSSpinLock os_unfair_lock;
|
||||
typedef OSSpinLock *os_unfair_lock_t;
|
||||
|
||||
__MP__BEGIN_DECLS
|
||||
|
||||
void os_unfair_lock_lock(os_unfair_lock_t lock);
|
||||
|
||||
bool os_unfair_lock_trylock(os_unfair_lock_t lock);
|
||||
|
||||
void os_unfair_lock_unlock(os_unfair_lock_t lock);
|
||||
|
||||
__MP__END_DECLS
|
||||
|
||||
/*
|
||||
it is not clear how to implement these functions
|
||||
|
||||
void os_unfair_lock_assert_owner(const os_unfair_lock *lock);
|
||||
void os_unfair_lock_assert_not_owner(const os_unfair_lock *lock);
|
||||
*/
|
||||
|
||||
#else /*__MP_LEGACY_SUPPORT_OS_UNFAIR_LOCK__*/
|
||||
|
||||
/* Include the primary system os/lock.h */
|
||||
#include_next <os/lock.h>
|
||||
|
||||
#endif /*__MP_LEGACY_SUPPORT_OS_UNFAIR_LOCK__*/
|
||||
|
||||
#endif
|
43
extern/macports-legacy-support/include/pthread.h
vendored
Normal file
43
extern/macports-legacy-support/include/pthread.h
vendored
Normal file
|
@ -0,0 +1,43 @@
|
|||
|
||||
/*
|
||||
* Copyright (c) 2018
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef _MACPORTS_PTHREAD_H_
|
||||
#define _MACPORTS_PTHREAD_H_
|
||||
|
||||
/* MP support header */
|
||||
#include "MacportsLegacySupport.h"
|
||||
|
||||
/* Include the primary system pthread.h */
|
||||
#include_next <pthread.h>
|
||||
|
||||
#if __MP_LEGACY_SUPPORT_PTHREAD_RWLOCK__
|
||||
/* PTHREAD_RWLOCK_INITIALIZER is not defined on Tiger */
|
||||
#ifndef PTHREAD_RWLOCK_INITIALIZER
|
||||
#define PTHREAD_RWLOCK_INITIALIZER {_PTHREAD_RWLOCK_SIG_init, {0}}
|
||||
#endif
|
||||
#endif /* __MP_LEGACY_SUPPORT_PTHREAD_RWLOCK__ */
|
||||
|
||||
|
||||
__MP__BEGIN_DECLS
|
||||
|
||||
#if __MP_LEGACY_SUPPORT_PTHREAD_SETNAME_NP__
|
||||
int pthread_setname_np(const char *);
|
||||
#endif /* __MP_LEGACY_SUPPORT_PTHREAD_SETNAME_NP__ */
|
||||
|
||||
__MP__END_DECLS
|
||||
|
||||
#endif /* _MACPORTS_PTHREAD_H_ */
|
34
extern/macports-legacy-support/include/pthread_impl.h
vendored
Normal file
34
extern/macports-legacy-support/include/pthread_impl.h
vendored
Normal file
|
@ -0,0 +1,34 @@
|
|||
|
||||
/*
|
||||
* Copyright (c) 2018
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef _MACPORTS_PTHREAD_IMPL_H_
|
||||
#define _MACPORTS_PTHREAD_IMPL_H_
|
||||
|
||||
/* MP support header */
|
||||
#include "MacportsLegacySupport.h"
|
||||
|
||||
/* Include the primary system pthread_impl.h */
|
||||
#include_next <pthread_impl.h>
|
||||
|
||||
#if __MP_LEGACY_SUPPORT_PTHREAD_RWLOCK__
|
||||
/* PTHREAD_RWLOCK_INITIALIZER is not defined on Tiger */
|
||||
#ifndef _PTHREAD_RWLOCK_SIG_init
|
||||
#define _PTHREAD_RWLOCK_SIG_init 0x2DA8B3B4
|
||||
#endif
|
||||
#endif /* __MP_LEGACY_SUPPORT_PTHREAD_RWLOCK__ */
|
||||
|
||||
#endif /* _MACPORTS_PTHREAD_IMPL_H_ */
|
102
extern/macports-legacy-support/include/stdio.h
vendored
Normal file
102
extern/macports-legacy-support/include/stdio.h
vendored
Normal file
|
@ -0,0 +1,102 @@
|
|||
|
||||
/*
|
||||
* Copyright (c) 2018 Chris Jones <jonesc@macports.org>
|
||||
* Copyright (c) 2018
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef _MACPORTS_STDIO_H_
|
||||
#define _MACPORTS_STDIO_H_
|
||||
|
||||
/* MP support header */
|
||||
#include "MacportsLegacySupport.h"
|
||||
|
||||
/* Include the primary system time.h */
|
||||
#include_next <stdio.h>
|
||||
|
||||
/* dprintf */
|
||||
#if __MP_LEGACY_SUPPORT_DPRINTF__
|
||||
|
||||
__MP__BEGIN_DECLS
|
||||
extern int dprintf(int fd, const char * __restrict format, ...);
|
||||
__MP__END_DECLS
|
||||
|
||||
#endif /* __MP_LEGACY_SUPPORT_DPRINTF__ */
|
||||
|
||||
/* getline */
|
||||
#if __MP_LEGACY_SUPPORT_GETLINE__
|
||||
|
||||
/*
|
||||
* [XSI] The ssize_t and size_t types shall be defined as described
|
||||
* in <sys/types.h>.
|
||||
*/
|
||||
#ifndef _SIZE_T
|
||||
#define _SIZE_T
|
||||
typedef __darwin_size_t size_t;
|
||||
#endif
|
||||
|
||||
#ifndef _SSIZE_T
|
||||
#define _SSIZE_T
|
||||
typedef __darwin_ssize_t ssize_t;
|
||||
#endif
|
||||
|
||||
__MP__BEGIN_DECLS
|
||||
extern ssize_t getdelim(char **lineptr, size_t *n, int delimiter, FILE *fp);
|
||||
extern ssize_t getline (char **lineptr, size_t *n, FILE *stream);
|
||||
__MP__END_DECLS
|
||||
|
||||
#endif /* __MP_LEGACY_SUPPORT_GETLINE__ */
|
||||
|
||||
/* open_memstream */
|
||||
#if __MP_LEGACY_SUPPORT_OPEN_MEMSTREAM__
|
||||
|
||||
__MP__BEGIN_DECLS
|
||||
FILE *open_memstream(char **ptr, size_t *sizeloc);
|
||||
__MP__END_DECLS
|
||||
|
||||
#endif /* __MP_LEGACY_SUPPORT_OPEN_MEMSTREAM__ */
|
||||
|
||||
/* fmemopen */
|
||||
#if __MP_LEGACY_SUPPORT_FMEMOPEN__
|
||||
|
||||
__MP__BEGIN_DECLS
|
||||
FILE *fmemopen(void *buf, size_t size, const char *mode);
|
||||
__MP__END_DECLS
|
||||
|
||||
#endif /* __MP_LEGACY_SUPPORT_FMEMOPEN__ */
|
||||
|
||||
/* renameat */
|
||||
#if __MP_LEGACY_SUPPORT_ATCALLS__
|
||||
|
||||
/*
|
||||
* [XSI] The ssize_t and size_t types shall be defined as described
|
||||
* in <sys/types.h>.
|
||||
*/
|
||||
#ifndef _SIZE_T
|
||||
#define _SIZE_T
|
||||
typedef __darwin_size_t size_t;
|
||||
#endif
|
||||
|
||||
#ifndef _SSIZE_T
|
||||
#define _SSIZE_T
|
||||
typedef __darwin_ssize_t ssize_t;
|
||||
#endif
|
||||
|
||||
__MP__BEGIN_DECLS
|
||||
extern int renameat(int olddirfd, const char *oldpath, int newdirfd, const char *newpath);
|
||||
__MP__END_DECLS
|
||||
|
||||
#endif /* __MP_LEGACY_SUPPORT_ATCALLS__ */
|
||||
|
||||
#endif /* _MACPORTS_STDIO_H_ */
|
79
extern/macports-legacy-support/include/stdlib.h
vendored
Normal file
79
extern/macports-legacy-support/include/stdlib.h
vendored
Normal file
|
@ -0,0 +1,79 @@
|
|||
|
||||
/*
|
||||
* Copyright (c) 2018 Chris Jones <jonesc@macports.org>
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef _MACPORTS_STDLIB_H_
|
||||
#define _MACPORTS_STDLIB_H_
|
||||
|
||||
/* MP support header */
|
||||
#include "MacportsLegacySupport.h"
|
||||
|
||||
/* Include the primary system stdlib.h */
|
||||
#include_next <stdlib.h>
|
||||
|
||||
/* posix_memalign */
|
||||
#if __MP_LEGACY_SUPPORT_POSIX_MEMALIGN__
|
||||
|
||||
/*
|
||||
* [XSI] The ssize_t and size_t types shall be defined as described
|
||||
* in <sys/types.h>.
|
||||
*/
|
||||
#ifndef _SIZE_T
|
||||
#define _SIZE_T
|
||||
typedef __darwin_size_t size_t;
|
||||
#endif
|
||||
|
||||
#ifndef _SSIZE_T
|
||||
#define _SSIZE_T
|
||||
typedef __darwin_ssize_t ssize_t;
|
||||
#endif
|
||||
|
||||
__MP__BEGIN_DECLS
|
||||
extern int posix_memalign(void **memptr, size_t alignment, size_t size);
|
||||
__MP__END_DECLS
|
||||
|
||||
#endif /* __MP_LEGACY_SUPPORT_POSIX_MEMALIGN__ */
|
||||
|
||||
/* arc4random */
|
||||
#if __MP_LEGACY_SUPPORT_ARC4RANDOM__
|
||||
|
||||
#ifndef _SIZE_T
|
||||
#define _SIZE_T
|
||||
typedef __darwin_size_t size_t;
|
||||
#endif
|
||||
#ifndef _UINT32_T
|
||||
#define _UINT32_T
|
||||
typedef unsigned int uint32_t;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Generate and return a uniformly random 32-bit quantity with an
|
||||
* upper bound of 'upper_bound'
|
||||
*/
|
||||
__MP__BEGIN_DECLS
|
||||
extern uint32_t arc4random_uniform( uint32_t upper_bound );
|
||||
__MP__END_DECLS
|
||||
|
||||
/*
|
||||
* Generate 'n' random bytes and put them in 'buf'.
|
||||
*/
|
||||
__MP__BEGIN_DECLS
|
||||
extern void arc4random_buf( void* buf, size_t n );
|
||||
__MP__END_DECLS
|
||||
|
||||
#endif /* __MP_LEGACY_SUPPORT_ARC4RANDOM__ */
|
||||
|
||||
#endif /* _MACPORTS_STDLIB_H_ */
|
56
extern/macports-legacy-support/include/string.h
vendored
Normal file
56
extern/macports-legacy-support/include/string.h
vendored
Normal file
|
@ -0,0 +1,56 @@
|
|||
|
||||
/*
|
||||
* Copyright (c) 2018 Chris Jones <jonesc@macports.org>
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef _MACPORTS_STRING_H_
|
||||
#define _MACPORTS_STRING_H_
|
||||
|
||||
/* MP support header */
|
||||
#include "MacportsLegacySupport.h"
|
||||
|
||||
/* Include the primary system string.h */
|
||||
#include_next <string.h>
|
||||
|
||||
/* stpncpy */
|
||||
#if __MP_LEGACY_SUPPORT_STPNCPY__
|
||||
__MP__BEGIN_DECLS
|
||||
extern char *stpncpy(char *dst, const char *src, size_t n);
|
||||
__MP__END_DECLS
|
||||
#endif
|
||||
|
||||
/* strnlen */
|
||||
#if __MP_LEGACY_SUPPORT_STRNLEN__
|
||||
__MP__BEGIN_DECLS
|
||||
extern size_t strnlen(const char *s, size_t maxlen);
|
||||
__MP__END_DECLS
|
||||
#endif
|
||||
|
||||
/* strndup */
|
||||
#if __MP_LEGACY_SUPPORT_STRNDUP__
|
||||
__MP__BEGIN_DECLS
|
||||
extern char *strndup(const char *s, size_t n);
|
||||
__MP__END_DECLS
|
||||
#endif
|
||||
|
||||
/* memmem */
|
||||
#if __MP_LEGACY_SUPPORT_MEMMEM__
|
||||
__MP__BEGIN_DECLS
|
||||
extern void *
|
||||
memmem(const void *l, size_t l_len, const void *s, size_t s_len);
|
||||
__MP__END_DECLS
|
||||
#endif
|
||||
|
||||
#endif /* _MACPORTS_STRING_H_ */
|
62
extern/macports-legacy-support/include/strings.h
vendored
Normal file
62
extern/macports-legacy-support/include/strings.h
vendored
Normal file
|
@ -0,0 +1,62 @@
|
|||
|
||||
/*
|
||||
* Copyright (c) 2020 Chris Jones <jonesc@macports.org>
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef _MACPORTS_STRINGS_H_
|
||||
#define _MACPORTS_STRINGS_H_
|
||||
|
||||
/* MP support header */
|
||||
#include "MacportsLegacySupport.h"
|
||||
|
||||
/* Include the primary system string.h */
|
||||
#include_next <strings.h>
|
||||
|
||||
/* ffsl */
|
||||
#if __MP_LEGACY_SUPPORT_FFSL__
|
||||
__MP__BEGIN_DECLS
|
||||
extern int ffsl(long int);
|
||||
__MP__END_DECLS
|
||||
#endif
|
||||
|
||||
/* ffsll */
|
||||
#if __MP_LEGACY_SUPPORT_FFSLL__
|
||||
__MP__BEGIN_DECLS
|
||||
extern int ffsll(long long int);
|
||||
__MP__END_DECLS
|
||||
#endif
|
||||
|
||||
/* fls */
|
||||
#if __MP_LEGACY_SUPPORT_FLS__
|
||||
__MP__BEGIN_DECLS
|
||||
extern int fls(int);
|
||||
__MP__END_DECLS
|
||||
#endif
|
||||
|
||||
/* flsl */
|
||||
#if __MP_LEGACY_SUPPORT_FLSL__
|
||||
__MP__BEGIN_DECLS
|
||||
extern int flsl(long int);
|
||||
__MP__END_DECLS
|
||||
#endif
|
||||
|
||||
/* flsll */
|
||||
#if __MP_LEGACY_SUPPORT_FLSLL__
|
||||
__MP__BEGIN_DECLS
|
||||
extern int flsll(long long int);
|
||||
__MP__END_DECLS
|
||||
#endif
|
||||
|
||||
#endif /* _MACPORTS_STRINGS_H_ */
|
57
extern/macports-legacy-support/include/sys/aio.h
vendored
Normal file
57
extern/macports-legacy-support/include/sys/aio.h
vendored
Normal file
|
@ -0,0 +1,57 @@
|
|||
|
||||
/*
|
||||
* Copyright (c) 2020
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef _MACPORTS_SYS_AIO_H_
|
||||
#define _MACPORTS_SYS_AIO_H_
|
||||
|
||||
/* MP support header */
|
||||
#include "MacportsLegacySupport.h"
|
||||
|
||||
|
||||
/* in the MacOSX10.4.sdk, several definitions are missing from this file that are included
|
||||
in later SDKs. This fix includes the headers in the order used in this file
|
||||
later SDKs, and adds the two missing definitions prior to calling the
|
||||
usual header.
|
||||
|
||||
The alternate method here would be to copy in the header from the
|
||||
MacOSX10.4.sdk and patch it in place, as is done in gcc. We may do that
|
||||
in the end, if it turns out to be less intrusive.
|
||||
|
||||
*/
|
||||
|
||||
#if __MP_LEGACY_SUPPORT_SYSAIOTIGERFIX__
|
||||
|
||||
#include <sys/signal.h>
|
||||
#include <sys/_types.h>
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
#ifndef _OFF_T
|
||||
typedef __darwin_off_t off_t;
|
||||
#define _OFF_T
|
||||
#endif
|
||||
|
||||
#ifndef _SSIZE_T
|
||||
#define _SSIZE_T
|
||||
typedef __darwin_ssize_t ssize_t;
|
||||
#endif
|
||||
|
||||
#endif /* __MP_LEGACY_SUPPORT_SYSAIOTIGERFIX__ */
|
||||
|
||||
/* Include the primary system sys/aio.h */
|
||||
#include_next <sys/aio.h>
|
||||
|
||||
#endif /* _MACPORTS_SYS_AIO_H_ */
|
64
extern/macports-legacy-support/include/sys/fcntl.h
vendored
Normal file
64
extern/macports-legacy-support/include/sys/fcntl.h
vendored
Normal file
|
@ -0,0 +1,64 @@
|
|||
|
||||
/*
|
||||
* Copyright (c) 2018 Chris Jones <jonesc@macports.org>
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef _MACPORTS_SYSFCNTL_H_
|
||||
#define _MACPORTS_SYSFCNTL_H_
|
||||
|
||||
/* MP support header */
|
||||
#include "MacportsLegacySupport.h"
|
||||
|
||||
/* Include the primary system fcntl.h */
|
||||
#include_next <sys/fcntl.h>
|
||||
|
||||
/* replace missing O_CLOEXEC definition with 0, which works
|
||||
* but does not replace the full function of that flag
|
||||
* this is the commonly done fix in MacPorts (see gtk3, for example)
|
||||
* FIXME - this could use a proper fix, if possible
|
||||
*/
|
||||
|
||||
#ifndef O_CLOEXEC
|
||||
#define O_CLOEXEC 0
|
||||
#endif
|
||||
|
||||
/* atcalls */
|
||||
#if __MP_LEGACY_SUPPORT_ATCALLS__
|
||||
|
||||
#ifndef AT_FDCWD
|
||||
#define AT_FDCWD -2
|
||||
#endif
|
||||
#ifndef AT_EACCESS
|
||||
#define AT_EACCESS 0x0010 /* Use effective ids in access check */
|
||||
#endif
|
||||
#ifndef AT_SYMLINK_NOFOLLOW
|
||||
#define AT_SYMLINK_NOFOLLOW 0x0020 /* Act on the symlink itself not the target */
|
||||
#endif
|
||||
#ifndef AT_SYMLINK_FOLLOW
|
||||
#define AT_SYMLINK_FOLLOW 0x0040 /* Act on target of symlink */
|
||||
#endif
|
||||
#ifndef AT_REMOVEDIR
|
||||
#define AT_REMOVEDIR 0x0080 /* Path refers to directory */
|
||||
#endif
|
||||
|
||||
__MP__BEGIN_DECLS
|
||||
|
||||
extern int openat(int dirfd, const char *pathname, int flags, ...);
|
||||
|
||||
__MP__END_DECLS
|
||||
|
||||
#endif /* __MP_LEGACY_SUPPORT_ATCALLS__ */
|
||||
|
||||
#endif /* _MACPORTS_SYSFCNTL_H_ */
|
46
extern/macports-legacy-support/include/sys/fsgetpath.h
vendored
Normal file
46
extern/macports-legacy-support/include/sys/fsgetpath.h
vendored
Normal file
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* Copyright (c) 2019
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef _MACPORTS_FSGETPATH_H_
|
||||
#define _MACPORTS_FSGETPATH_H_
|
||||
|
||||
/* MP support header */
|
||||
#include "MacportsLegacySupport.h"
|
||||
|
||||
#if defined(__has_include_next)
|
||||
#if __has_include_next(<sys/fsgetpath.h>)
|
||||
|
||||
/* Include the primary system sys/fsgetpath.h */
|
||||
#include_next <sys/fsgetpath.h>
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if __MP_LEGACY_SUPPORT_FSGETPATH__
|
||||
|
||||
#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1060
|
||||
|
||||
__MP__BEGIN_DECLS
|
||||
extern ssize_t fsgetpath(char * __restrict buf, size_t bufsize, fsid_t* fsid, uint64_t objid);
|
||||
__MP__END_DECLS
|
||||
|
||||
#else
|
||||
#error "No implementation of fsgetpath is presently available for MacOSX prior to 10.6"
|
||||
#endif /* __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1060 */
|
||||
|
||||
#endif /* __MP_LEGACY_SUPPORT_FSGETPATH__ */
|
||||
|
||||
#endif /* _MACPORTS_FSGETPATH_H_ */
|
33
extern/macports-legacy-support/include/sys/mman.h
vendored
Normal file
33
extern/macports-legacy-support/include/sys/mman.h
vendored
Normal file
|
@ -0,0 +1,33 @@
|
|||
|
||||
/*
|
||||
* Copyright (c) 2018 Chris Jones <jonesc@macports.org>
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef _MACPORTS_MMAN_H_
|
||||
#define _MACPORTS_MMAN_H_
|
||||
|
||||
/* MP support header */
|
||||
#include "MacportsLegacySupport.h"
|
||||
|
||||
/* Include the primary system sys/mman.h */
|
||||
#include_next <sys/mman.h>
|
||||
|
||||
/* MAP_ANONYMOUS only exists on 10.11+ */
|
||||
/* Prior to that it was called MAP_ANON */
|
||||
#ifndef MAP_ANONYMOUS
|
||||
#define MAP_ANONYMOUS MAP_ANON
|
||||
#endif
|
||||
|
||||
#endif /* _MACPORTS_MMAN_H_ */
|
39
extern/macports-legacy-support/include/sys/queue.h
vendored
Normal file
39
extern/macports-legacy-support/include/sys/queue.h
vendored
Normal file
|
@ -0,0 +1,39 @@
|
|||
|
||||
/*
|
||||
* Copyright (c) 2018 Chris Jones <jonesc@macports.org>
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef _MACPORTS_SYS_QUEUE_H_
|
||||
#define _MACPORTS_SYS_QUEUE_H_
|
||||
|
||||
/* MP support header */
|
||||
#include "MacportsLegacySupport.h"
|
||||
|
||||
/* Include the primary system sys/queue.h */
|
||||
#include_next <sys/queue.h>
|
||||
|
||||
#if __MP_LEGACY_SUPPORT_STAILQ_FOREACH__
|
||||
/* STAILQ_FOREACH is not defined on Tiger */
|
||||
|
||||
#ifndef STAILQ_FOREACH
|
||||
#define STAILQ_FOREACH(var, head, field) \
|
||||
for((var) = STAILQ_FIRST((head)); \
|
||||
(var); \
|
||||
(var) = STAILQ_NEXT((var), field))
|
||||
#endif
|
||||
|
||||
#endif /* __MP_LEGACY_SUPPORT_STAILQ_FOREACH__ */
|
||||
|
||||
#endif /* _MACPORTS_SYS_QUEUE_H_ */
|
37
extern/macports-legacy-support/include/sys/random.h
vendored
Normal file
37
extern/macports-legacy-support/include/sys/random.h
vendored
Normal file
|
@ -0,0 +1,37 @@
|
|||
|
||||
/*
|
||||
* Copyright (c) 2021
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef _MACPORTS_SYSRANDOM_H_
|
||||
#define _MACPORTS_SYSRANDOM_H_
|
||||
|
||||
/* MP support header */
|
||||
#include "MacportsLegacySupport.h"
|
||||
|
||||
/* Include the primary system random.h */
|
||||
#include_next <sys/random.h>
|
||||
|
||||
#if __MP_LEGACY_SUPPORT_GETENTROPY__
|
||||
|
||||
__MP__BEGIN_DECLS
|
||||
|
||||
extern int getentropy(void *buf, size_t buflen);
|
||||
|
||||
__MP__END_DECLS
|
||||
|
||||
#endif /* __MP_LEGACY_SUPPORT_GETENTROPY__ */
|
||||
|
||||
#endif /* _MACPORTS_SYSRANDOM_H_ */
|
48
extern/macports-legacy-support/include/sys/socket.h
vendored
Normal file
48
extern/macports-legacy-support/include/sys/socket.h
vendored
Normal file
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* Copyright (c) 2024 Frederick H. G. Wright II <fw@fwright.net>
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef _MACPORTS_SYS_SOCKET_H_
|
||||
#define _MACPORTS_SYS_SOCKET_H_
|
||||
|
||||
/* MP support header */
|
||||
#include "MacportsLegacySupport.h"
|
||||
|
||||
/* Include the primary system sys/socket.h */
|
||||
#include_next <sys/socket.h>
|
||||
|
||||
/*
|
||||
* OSX prior to 10.6 defines CMSG_DATA without properly considering 64-bit
|
||||
* builds, due to bad alignment assumptions, though it happens to work in
|
||||
* the 10.4 case and only actually fails in the 10.5 64-bit case.
|
||||
*
|
||||
* In those OS versions we substitute a version of the definition from 10.6.
|
||||
*/
|
||||
|
||||
#if __MP_LEGACY_SUPPORT_CMSG_DATA_FIX__
|
||||
|
||||
#define __DARWIN_ALIGNBYTES32 (sizeof(__uint32_t) - 1)
|
||||
#define __DARWIN_ALIGN32(p) \
|
||||
((size_t)((char *)(size_t)(p) \
|
||||
+ __DARWIN_ALIGNBYTES32) &~ __DARWIN_ALIGNBYTES32)
|
||||
|
||||
/* given pointer to struct cmsghdr, return pointer to data */
|
||||
#undef CMSG_DATA
|
||||
#define CMSG_DATA(cmsg) ((unsigned char *)(cmsg) + \
|
||||
__DARWIN_ALIGN32(sizeof(struct cmsghdr)))
|
||||
|
||||
#endif /* __MP_LEGACY_SUPPORT_CMSG_DATA_FIX__ */
|
||||
|
||||
#endif /* _MACPORTS_SYS_SOCKET_H_ */
|
39
extern/macports-legacy-support/include/sys/spawn.h
vendored
Normal file
39
extern/macports-legacy-support/include/sys/spawn.h
vendored
Normal file
|
@ -0,0 +1,39 @@
|
|||
|
||||
/*
|
||||
* Copyright (c) 2020
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef _MACPORTS_SYS_SPAWN_H_
|
||||
#define _MACPORTS_SYS_SPAWN_H_
|
||||
|
||||
/* MP support header */
|
||||
#include "MacportsLegacySupport.h"
|
||||
|
||||
/* spawn.h exists on Leopard or later. Use this block method at present
|
||||
* because gcc versions < 5 don't recognize __have_include()
|
||||
*/
|
||||
#if (__APPLE__ && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1050)
|
||||
|
||||
/* Include the primary system sys/queue.h */
|
||||
#include_next <sys/spawn.h>
|
||||
|
||||
/* replace if missing */
|
||||
#ifndef POSIX_SPAWN_CLOEXEC_DEFAULT
|
||||
#define POSIX_SPAWN_CLOEXEC_DEFAULT 0x4000
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* _MACPORTS_SYS_SPAWN_H_ */
|
76
extern/macports-legacy-support/include/sys/stat.h
vendored
Normal file
76
extern/macports-legacy-support/include/sys/stat.h
vendored
Normal file
|
@ -0,0 +1,76 @@
|
|||
|
||||
/*
|
||||
* Copyright (c) 2018 Chris Jones <jonesc@macports.org>
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef _MACPORTS_SYSSTAT_H_
|
||||
#define _MACPORTS_SYSSTAT_H_
|
||||
|
||||
/* MP support header */
|
||||
#include "MacportsLegacySupport.h"
|
||||
|
||||
/* Include the primary system stat.h */
|
||||
#include_next <sys/stat.h>
|
||||
|
||||
#if __MP_LEGACY_SUPPORT_UTIMENSAT__
|
||||
|
||||
#if !defined(UTIME_NOW)
|
||||
#define UTIME_NOW -1
|
||||
#endif
|
||||
|
||||
#if !defined(UTIME_OMIT)
|
||||
#define UTIME_OMIT -2
|
||||
#endif
|
||||
|
||||
__MP__BEGIN_DECLS
|
||||
|
||||
extern int futimens(int fd, const struct timespec _times_in[2]);
|
||||
extern int utimensat(int fd, const char *path, const struct timespec _times_in[2], int flags);
|
||||
|
||||
__MP__END_DECLS
|
||||
|
||||
#endif /* __MP_LEGACY_SUPPORT_UTIMENSAT__ */
|
||||
|
||||
|
||||
#if __MP_LEGACY_SUPPORT_ATCALLS__
|
||||
|
||||
__MP__BEGIN_DECLS
|
||||
|
||||
extern int fchmodat(int dirfd, const char *pathname, mode_t mode, int flags);
|
||||
extern int fstatat(int dirfd, const char *pathname, struct stat *buf, int flags);
|
||||
|
||||
/* 64bit inode types appeared only on 10.5, and currently can't be replaced on Tiger */
|
||||
/* due to lack of kernel support for the underlying syscalls */
|
||||
#if !__DARWIN_ONLY_64_BIT_INO_T && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1050
|
||||
extern int fstatat64(int dirfd, const char *pathname, struct stat64 *buf, int flags);
|
||||
#endif
|
||||
|
||||
extern int mkdirat(int dirfd, const char *pathname, mode_t mode);
|
||||
|
||||
__MP__END_DECLS
|
||||
|
||||
#endif /* __MP_LEGACY_SUPPORT_ATCALLS__ */
|
||||
|
||||
#if __MP_LEGACY_SUPPORT_LSMOD__
|
||||
|
||||
__MP__BEGIN_DECLS
|
||||
|
||||
extern int lchmod(const char *, mode_t);
|
||||
|
||||
__MP__END_DECLS
|
||||
|
||||
#endif /* __MP_LEGACY_SUPPORT_LSMOD__ */
|
||||
|
||||
#endif /* _MACPORTS_SYSSTAT_H_ */
|
37
extern/macports-legacy-support/include/sys/time.h
vendored
Normal file
37
extern/macports-legacy-support/include/sys/time.h
vendored
Normal file
|
@ -0,0 +1,37 @@
|
|||
|
||||
/*
|
||||
* Copyright (c) 2020
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef _MACPORTS_SYSTIME_H_
|
||||
#define _MACPORTS_SYSTIME_H_
|
||||
|
||||
/* MP support header */
|
||||
#include "MacportsLegacySupport.h"
|
||||
|
||||
/* Include the primary system time.h */
|
||||
#include_next <sys/time.h>
|
||||
|
||||
#if __MP_LEGACY_SUPPORT_LUTIMES__
|
||||
|
||||
__MP__BEGIN_DECLS
|
||||
|
||||
extern int lutimes(const char *, const struct timeval *);
|
||||
|
||||
__MP__END_DECLS
|
||||
|
||||
#endif /* __MP_LEGACY_SUPPORT_LUTIMES__ */
|
||||
|
||||
#endif /* _MACPORTS_SYSTIME_H_ */
|
93
extern/macports-legacy-support/include/sys/unistd.h
vendored
Normal file
93
extern/macports-legacy-support/include/sys/unistd.h
vendored
Normal file
|
@ -0,0 +1,93 @@
|
|||
|
||||
/*
|
||||
* Copyright (c) 2018 Chris Jones <jonesc@macports.org>
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef _MACPORTS_SYSUNISTD_H_
|
||||
#define _MACPORTS_SYSUNISTD_H_
|
||||
|
||||
/* MP support header */
|
||||
#include "MacportsLegacySupport.h"
|
||||
|
||||
/* Include the primary system unistd.h */
|
||||
#include_next <sys/unistd.h>
|
||||
|
||||
/* For types such as uint32_t. */
|
||||
#include <stdint.h>
|
||||
|
||||
#if __MP_LEGACY_SUPPORT_ATCALLS__
|
||||
|
||||
/*
|
||||
* [XSI] The ssize_t and size_t types shall be defined as described
|
||||
* in <sys/types.h>.
|
||||
*/
|
||||
#ifndef _SIZE_T
|
||||
#define _SIZE_T
|
||||
typedef __darwin_size_t size_t;
|
||||
#endif
|
||||
|
||||
#ifndef _SSIZE_T
|
||||
#define _SSIZE_T
|
||||
typedef __darwin_ssize_t ssize_t;
|
||||
#endif
|
||||
|
||||
#ifndef _UID_T
|
||||
#define _UID_T
|
||||
typedef __darwin_uid_t uid_t; /* user id */
|
||||
#endif
|
||||
|
||||
#ifndef _GID_T
|
||||
#define _GID_T
|
||||
typedef __darwin_gid_t gid_t;
|
||||
#endif
|
||||
|
||||
__MP__BEGIN_DECLS
|
||||
|
||||
extern int getattrlistat(int dirfd, const char *pathname, void *a,
|
||||
void *buf, size_t size, unsigned long flags);
|
||||
extern ssize_t readlinkat(int dirfd, const char *pathname, char *buf, size_t bufsiz);
|
||||
extern int faccessat(int dirfd, const char *pathname, int mode, int flags);
|
||||
extern int fchownat(int dirfd, const char *pathname, uid_t owner, gid_t group, int flags);
|
||||
extern int linkat(int olddirfd, const char *oldpath, int newdirfd, const char *newpath, int flags);
|
||||
extern int symlinkat(const char *oldpath, int newdirfd, const char *newpath);
|
||||
extern int unlinkat(int dirfd, const char *pathname, int flags);
|
||||
|
||||
__MP__END_DECLS
|
||||
|
||||
#endif /* __MP_LEGACY_SUPPORT_ATCALLS__ */
|
||||
|
||||
|
||||
#if __MP_LEGACY_SUPPORT_SETATTRLISTAT__
|
||||
|
||||
/*
|
||||
* [XSI] The ssize_t and size_t types shall be defined as described
|
||||
* in <sys/types.h>.
|
||||
*/
|
||||
#ifndef _SIZE_T
|
||||
#define _SIZE_T
|
||||
typedef __darwin_size_t size_t;
|
||||
#endif
|
||||
|
||||
|
||||
__MP__BEGIN_DECLS
|
||||
|
||||
extern int setattrlistat(int dirfd, const char *pathname, void *a,
|
||||
void *buf, size_t size, uint32_t flags);
|
||||
|
||||
__MP__END_DECLS
|
||||
|
||||
#endif /* __MP_LEGACY_SUPPORT_SETATTRLISTAT__ */
|
||||
|
||||
#endif /* _MACPORTS_SYSUNISTD_H_ */
|
105
extern/macports-legacy-support/include/time.h
vendored
Normal file
105
extern/macports-legacy-support/include/time.h
vendored
Normal file
|
@ -0,0 +1,105 @@
|
|||
|
||||
/*
|
||||
* Copyright (c) 2018 Chris Jones <jonesc@macports.org>
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef _MACPORTS_TIME_H_
|
||||
#define _MACPORTS_TIME_H_
|
||||
|
||||
/* MP support header */
|
||||
#include "MacportsLegacySupport.h"
|
||||
|
||||
/* Include the primary system time.h */
|
||||
#include_next <time.h>
|
||||
|
||||
/* The following functions are implemented by Tiger, but the declarations are
|
||||
* missing if _ANSI_SOURCE or _POSIX_C_SOURCE are defined, which occurs when
|
||||
* _XOPEN_SOURCE is set. */
|
||||
#if __MP_LEGACY_SUPPORT_TIME_THREAD_SAFE_FUNCTIONS__
|
||||
|
||||
__MP__BEGIN_DECLS
|
||||
#if defined(_ANSI_SOURCE) || defined(_POSIX_C_SOURCE)
|
||||
char *asctime_r(const struct tm *, char *);
|
||||
char *ctime_r(const time_t *, char *);
|
||||
struct tm *gmtime_r(const time_t *, struct tm *);
|
||||
struct tm *localtime_r(const time_t *, struct tm *);
|
||||
#endif /* defined(_ANSI_SOURCE) || defined(_POSIX_C_SOURCE) */
|
||||
__MP__END_DECLS
|
||||
|
||||
#endif /* __MP_LEGACY_SUPPORT_TIME_THREAD_SAFE_FUNCTIONS__ */
|
||||
|
||||
/* Legacy implementation of clock_gettime */
|
||||
#if __MP_LEGACY_SUPPORT_GETTIME__
|
||||
|
||||
/* One define types and methods if not already defined. */
|
||||
#if !defined(CLOCK_REALTIME) && !defined(CLOCK_MONOTONIC)
|
||||
typedef int clockid_t;
|
||||
#endif /* !defined(CLOCK_REALTIME) && !defined(CLOCK_MONOTONIC) */
|
||||
|
||||
#ifndef CLOCK_REALTIME
|
||||
#define CLOCK_REALTIME 0
|
||||
#endif
|
||||
#ifndef CLOCK_MONOTONIC
|
||||
#define CLOCK_MONOTONIC 6
|
||||
#endif
|
||||
|
||||
#ifndef CLOCK_MONOTONIC_RAW
|
||||
#define CLOCK_MONOTONIC_RAW 4
|
||||
#endif
|
||||
#ifndef CLOCK_MONOTONIC_RAW_APPROX
|
||||
#define CLOCK_MONOTONIC_RAW_APPROX 5
|
||||
#endif
|
||||
|
||||
#ifndef CLOCK_UPTIME_RAW
|
||||
#define CLOCK_UPTIME_RAW 8
|
||||
#endif
|
||||
|
||||
#ifndef CLOCK_UPTIME_RAW_APPROX
|
||||
#define CLOCK_UPTIME_RAW_APPROX 8
|
||||
#endif
|
||||
|
||||
#ifndef CLOCK_PROCESS_CPUTIME_ID
|
||||
#define CLOCK_PROCESS_CPUTIME_ID 12
|
||||
#endif
|
||||
|
||||
#ifndef CLOCK_THREAD_CPUTIME_ID
|
||||
#define CLOCK_THREAD_CPUTIME_ID 16
|
||||
#endif
|
||||
|
||||
__MP__BEGIN_DECLS
|
||||
|
||||
extern int clock_gettime( clockid_t clk_id, struct timespec *ts );
|
||||
extern int clock_getres ( clockid_t clk_id, struct timespec *ts );
|
||||
|
||||
__MP__END_DECLS
|
||||
|
||||
#endif /* __MP_LEGACY_SUPPORT_GETTIME__ */
|
||||
|
||||
/* Legacy implementation of timespec */
|
||||
#if __MP_LEGACY_SUPPORT_TIMESPEC_GET__
|
||||
|
||||
#ifndef TIME_UTC
|
||||
#define TIME_UTC 1 /* time elapsed since epoch */
|
||||
#endif
|
||||
|
||||
__MP__BEGIN_DECLS
|
||||
|
||||
extern int timespec_get(struct timespec *ts, int base);
|
||||
|
||||
__MP__END_DECLS
|
||||
|
||||
#endif /* __MP_LEGACY_SUPPORT_TIMESPEC_GET__ */
|
||||
|
||||
#endif /* _MACPORTS_TIME_H_ */
|
36
extern/macports-legacy-support/include/uuid/uuid.h
vendored
Normal file
36
extern/macports-legacy-support/include/uuid/uuid.h
vendored
Normal file
|
@ -0,0 +1,36 @@
|
|||
|
||||
/*
|
||||
* Copyright (c) 2022
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef _MACPORTS_UUIDUUID_H_
|
||||
#define _MACPORTS_UUIDUUID_H_
|
||||
|
||||
/* MP support header */
|
||||
#include "MacportsLegacySupport.h"
|
||||
|
||||
/* Include the primary system uuid/uuid.h */
|
||||
#include_next <uuid/uuid.h>
|
||||
|
||||
#if __MP_LEGACY_SUPPORT_UUID__
|
||||
|
||||
#ifndef _UUID_STRING_T
|
||||
#define _UUID_STRING_T
|
||||
typedef char uuid_string_t[37];
|
||||
#endif /* _UUID_STRING_T */
|
||||
|
||||
#endif /* __MP_LEGACY_SUPPORT_UTIMENSAT__ */
|
||||
|
||||
#endif /* _MACPORTS_UUIDUUID_H_ */
|
53
extern/macports-legacy-support/include/wchar.h
vendored
Normal file
53
extern/macports-legacy-support/include/wchar.h
vendored
Normal file
|
@ -0,0 +1,53 @@
|
|||
|
||||
/*
|
||||
* Copyright (c) 2018 Chris Jones <jonesc@macports.org>
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef _MACPORTS_WCHAR_H_
|
||||
#define _MACPORTS_WCHAR_H_
|
||||
|
||||
/* MP support header */
|
||||
#include "MacportsLegacySupport.h"
|
||||
|
||||
/* Include the primary system wchar.h */
|
||||
#include_next <wchar.h>
|
||||
|
||||
__MP__BEGIN_DECLS
|
||||
|
||||
/* wcsdup */
|
||||
#if __MP_LEGACY_SUPPORT_WCSDUP__
|
||||
extern wchar_t * wcsdup(const wchar_t *s);
|
||||
#endif
|
||||
|
||||
/* wcsnlen */
|
||||
#if __MP_LEGACY_SUPPORT_WCSNLEN__
|
||||
extern size_t wcsnlen(const wchar_t *, size_t);
|
||||
#endif
|
||||
|
||||
/* wcpcpy, wcpncpy */
|
||||
#if __MP_LEGACY_SUPPORT_WCPCPY__
|
||||
extern wchar_t * wcpcpy(wchar_t *__restrict d, const wchar_t *__restrict s);
|
||||
extern wchar_t *wcpncpy(wchar_t *__restrict d, const wchar_t *__restrict s, size_t n);
|
||||
#endif
|
||||
|
||||
/* wcsncasecmp, wcscasecmp */
|
||||
#if __MP_LEGACY_SUPPORT_WCSCASECMP__
|
||||
extern int wcscasecmp(const wchar_t *l, const wchar_t *r);
|
||||
extern int wcsncasecmp(const wchar_t *l, const wchar_t *r, size_t n);
|
||||
#endif
|
||||
|
||||
__MP__END_DECLS
|
||||
|
||||
#endif /* _MACPORTS_WCHAR_H_ */
|
35
extern/macports-legacy-support/include/xlocale/_wchar.h
vendored
Normal file
35
extern/macports-legacy-support/include/xlocale/_wchar.h
vendored
Normal file
|
@ -0,0 +1,35 @@
|
|||
|
||||
/*
|
||||
* Copyright (c) 2018 Christian Cornelssen
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef _MACPORTS_XLOCALE__WCHAR_H_
|
||||
#define _MACPORTS_XLOCALE__WCHAR_H_
|
||||
|
||||
/* Include the primary system xlocale/_wchar.h */
|
||||
#include_next <xlocale/_wchar.h>
|
||||
|
||||
/* MP support header */
|
||||
#include "MacportsLegacySupport.h"
|
||||
|
||||
/* wcsncasecmp_l, wcscasecmp_l */
|
||||
#if __MP_LEGACY_SUPPORT_WCSCASECMP__
|
||||
__MP__BEGIN_DECLS
|
||||
extern int wcscasecmp_l(const wchar_t *l, const wchar_t *r, locale_t locale);
|
||||
extern int wcsncasecmp_l(const wchar_t *l, const wchar_t *r, size_t n, locale_t locale);
|
||||
__MP__END_DECLS
|
||||
#endif
|
||||
|
||||
#endif /* _MACPORTS_XLOCALE__WCHAR_H_ */
|
83
extern/macports-legacy-support/src/add_symbols.c
vendored
Normal file
83
extern/macports-legacy-support/src/add_symbols.c
vendored
Normal file
|
@ -0,0 +1,83 @@
|
|||
#include "MacportsLegacySupport.h"
|
||||
|
||||
#if !(__MP_LEGACY_SUPPORT_POSIX_MEMALIGN__)
|
||||
extern const char posix_memalign_tmp4 __asm("$ld$add$os10.4$_posix_memalign"); __attribute__((visibility("default"))) const char posix_memalign_tmp4 = 0;
|
||||
extern const char posix_memalign_tmp5 __asm("$ld$add$os10.5$_posix_memalign"); __attribute__((visibility("default"))) const char posix_memalign_tmp5 = 0;
|
||||
#endif
|
||||
|
||||
#if !(__MP_LEGACY_SUPPORT_REALPATH_WRAP__)
|
||||
extern const char realpath_tmp4 __asm("$ld$add$os10.4$_realpath"); __attribute__((visibility("default"))) const char realpath_tmp4 = 0;
|
||||
extern const char realpath_tmp5 __asm("$ld$add$os10.5$_realpath$DARWIN_EXTSN"); __attribute__((visibility("default"))) const char realpath_tmp5 = 0;
|
||||
#endif
|
||||
|
||||
#if !(__MP_LEGACY_SUPPORT_SYSCONF_WRAP__)
|
||||
extern const char sysconf_tmp4 __asm("$ld$add$os10.4$_sysconf"); __attribute__((visibility("default"))) const char sysconf_tmp4 = 0;
|
||||
extern const char sysconf_tmp5 __asm("$ld$add$os10.5$_sysconf"); __attribute__((visibility("default"))) const char sysconf_tmp5 = 0;
|
||||
extern const char sysconf_tmp6 __asm("$ld$add$os10.6$_sysconf"); __attribute__((visibility("default"))) const char sysconf_tmp6 = 0;
|
||||
extern const char sysconf_tmp7 __asm("$ld$add$os10.7$_sysconf"); __attribute__((visibility("default"))) const char sysconf_tmp7 = 0;
|
||||
extern const char sysconf_tmp8 __asm("$ld$add$os10.8$_sysconf"); __attribute__((visibility("default"))) const char sysconf_tmp8 = 0;
|
||||
extern const char sysconf_tmp9 __asm("$ld$add$os10.9$_sysconf"); __attribute__((visibility("default"))) const char sysconf_tmp9 = 0;
|
||||
extern const char sysconf_tmp10 __asm("$ld$add$os10.10$_sysconf"); __attribute__((visibility("default"))) const char sysconf_tmp10 = 0;
|
||||
#endif
|
||||
|
||||
#if !(__MP_LEGACY_SUPPORT_PTHREAD_SETNAME_NP__)
|
||||
extern const char pthread_setname_np_tmp4 __asm("$ld$add$os10.4$_pthread_setname_np"); __attribute__((visibility("default"))) const char pthread_setname_np_tmp4 = 0;
|
||||
extern const char pthread_setname_np_tmp5 __asm("$ld$add$os10.5$_pthread_setname_np"); __attribute__((visibility("default"))) const char pthread_setname_np_tmp5 = 0;
|
||||
#endif
|
||||
|
||||
#if !(__MP_LEGACY_SUPPORT_COPYFILE_WRAP__)
|
||||
/* extern const char copyfile_state_get_tmp4 __asm("$ld$add$os10.4$_copyfile_state_get"); __attribute__((visibility("default"))) const char copyfile_state_get_tmp4 = 0; */
|
||||
extern const char copyfile_state_get_tmp5 __asm("$ld$add$os10.5$_copyfile_state_get"); __attribute__((visibility("default"))) const char copyfile_state_get_tmp5 = 0;
|
||||
#endif
|
||||
|
||||
#if !(__MP_LEGACY_SUPPORT_ATEXIT_WRAP__)
|
||||
extern const char _tlv_atexit_tmp4 __asm("$ld$add$os10.4$__tlv_atexit"); __attribute__((visibility("default"))) const char _tlv_atexit_tmp4 = 0;
|
||||
extern const char _tlv_atexit_tmp5 __asm("$ld$add$os10.5$__tlv_atexit"); __attribute__((visibility("default"))) const char _tlv_atexit_tmp5 = 0;
|
||||
extern const char _tlv_atexit_tmp6 __asm("$ld$add$os10.6$__tlv_atexit"); __attribute__((visibility("default"))) const char _tlv_atexit_tmp6 = 0;
|
||||
|
||||
extern const char __cxa_thread_atexit_tmp4 __asm("$ld$add$os10.4$___cxa_thread_atexit"); __attribute__((visibility("default"))) const char __cxa_thread_atexit_tmp4 = 0;
|
||||
extern const char __cxa_thread_atexit_tmp5 __asm("$ld$add$os10.5$___cxa_thread_atexit"); __attribute__((visibility("default"))) const char __cxa_thread_atexit_tmp5 = 0;
|
||||
extern const char __cxa_thread_atexit_tmp6 __asm("$ld$add$os10.6$___cxa_thread_atexit"); __attribute__((visibility("default"))) const char __cxa_thread_atexit_tmp6 = 0;
|
||||
#endif
|
||||
|
||||
#if !(__MP_LEGACY_SUPPORT_GETENTROPY__)
|
||||
extern const char getentropy_tmp4 __asm("$ld$add$os10.4$_getentropy"); __attribute__((visibility("default"))) const char getentropy_tmp4 = 0;
|
||||
extern const char getentropy_tmp5 __asm("$ld$add$os10.5$_getentropy"); __attribute__((visibility("default"))) const char getentropy_tmp5 = 0;
|
||||
extern const char getentropy_tmp6 __asm("$ld$add$os10.6$_getentropy"); __attribute__((visibility("default"))) const char getentropy_tmp6 = 0;
|
||||
extern const char getentropy_tmp7 __asm("$ld$add$os10.7$_getentropy"); __attribute__((visibility("default"))) const char getentropy_tmp7 = 0;
|
||||
extern const char getentropy_tmp8 __asm("$ld$add$os10.8$_getentropy"); __attribute__((visibility("default"))) const char getentropy_tmp8 = 0;
|
||||
extern const char getentropy_tmp9 __asm("$ld$add$os10.9$_getentropy"); __attribute__((visibility("default"))) const char getentropy_tmp9 = 0;
|
||||
extern const char getentropy_tmp10 __asm("$ld$add$os10.10$_getentropy"); __attribute__((visibility("default"))) const char getentropy_tmp10 = 0;
|
||||
extern const char getentropy_tmp11 __asm("$ld$add$os10.11$_getentropy"); __attribute__((visibility("default"))) const char getentropy_tmp11 = 0;
|
||||
#endif
|
||||
|
||||
#if !(__MP_LEGACY_SUPPORT_GETTIME__)
|
||||
extern const char clock_gettime_tmp4 __asm("$ld$add$os10.4$_clock_gettime"); __attribute__((visibility("default"))) const char clock_gettime_tmp4 = 0;
|
||||
extern const char clock_gettime_tmp5 __asm("$ld$add$os10.5$_clock_gettime"); __attribute__((visibility("default"))) const char clock_gettime_tmp5 = 0;
|
||||
extern const char clock_gettime_tmp6 __asm("$ld$add$os10.6$_clock_gettime"); __attribute__((visibility("default"))) const char clock_gettime_tmp6 = 0;
|
||||
extern const char clock_gettime_tmp7 __asm("$ld$add$os10.7$_clock_gettime"); __attribute__((visibility("default"))) const char clock_gettime_tmp7 = 0;
|
||||
extern const char clock_gettime_tmp8 __asm("$ld$add$os10.8$_clock_gettime"); __attribute__((visibility("default"))) const char clock_gettime_tmp8 = 0;
|
||||
extern const char clock_gettime_tmp9 __asm("$ld$add$os10.9$_clock_gettime"); __attribute__((visibility("default"))) const char clock_gettime_tmp9 = 0;
|
||||
extern const char clock_gettime_tmp10 __asm("$ld$add$os10.10$_clock_gettime"); __attribute__((visibility("default"))) const char clock_gettime_tmp10 = 0;
|
||||
extern const char clock_gettime_tmp11 __asm("$ld$add$os10.11$_clock_gettime"); __attribute__((visibility("default"))) const char clock_gettime_tmp11 = 0;
|
||||
#endif
|
||||
|
||||
#if !(__MP_LEGACY_SUPPORT_SYMBOL____bzero__)
|
||||
extern const char __bzero_tmp4 __asm("$ld$add$os10.4$___bzero"); __attribute__((visibility("default"))) const char __bzero_tmp4 = 0;
|
||||
extern const char __bzero_tmp5 __asm("$ld$add$os10.5$___bzero"); __attribute__((visibility("default"))) const char __bzero_tmp5 = 0;
|
||||
#endif
|
||||
|
||||
#if !(__MP_LEGACY_SUPPORT_SYMBOL__dirfd__)
|
||||
extern const char dirfd_tmp4 __asm("$ld$add$os10.4$_dirfd"); __attribute__((visibility("default"))) const char dirfd_tmp4 = 0;
|
||||
extern const char dirfd_tmp5 __asm("$ld$add$os10.5$_dirfd"); __attribute__((visibility("default"))) const char dirfd_tmp5 = 0;
|
||||
extern const char dirfd_tmp6 __asm("$ld$add$os10.6$_dirfd"); __attribute__((visibility("default"))) const char dirfd_tmp6 = 0;
|
||||
extern const char dirfd_tmp7 __asm("$ld$add$os10.7$_dirfd"); __attribute__((visibility("default"))) const char dirfd_tmp7 = 0;
|
||||
#endif
|
||||
|
||||
#if !(__MP_LEGACY_SUPPORT_ATCALLS__)
|
||||
extern const char fstatat$INODE64_tmp5 __asm("$ld$add$os10.5$_fstatat$INODE64"); __attribute__((visibility("default"))) const char fstatat$INODE64_tmp5 = 0;
|
||||
extern const char fstatat$INODE64_tmp6 __asm("$ld$add$os10.6$_fstatat$INODE64"); __attribute__((visibility("default"))) const char fstatat$INODE64_tmp6 = 0;
|
||||
extern const char fstatat$INODE64_tmp7 __asm("$ld$add$os10.7$_fstatat$INODE64"); __attribute__((visibility("default"))) const char fstatat$INODE64_tmp7 = 0;
|
||||
extern const char fstatat$INODE64_tmp8 __asm("$ld$add$os10.8$_fstatat$INODE64"); __attribute__((visibility("default"))) const char fstatat$INODE64_tmp8 = 0;
|
||||
extern const char fstatat$INODE64_tmp9 __asm("$ld$add$os10.9$_fstatat$INODE64"); __attribute__((visibility("default"))) const char fstatat$INODE64_tmp9 = 0;
|
||||
#endif
|
540
extern/macports-legacy-support/src/arc4random.c
vendored
Normal file
540
extern/macports-legacy-support/src/arc4random.c
vendored
Normal file
|
@ -0,0 +1,540 @@
|
|||
/*
|
||||
* Copyright (c) 1996, David Mazieres <dm@uun.org>
|
||||
* Copyright (c) 2008, Damien Miller <djm@openbsd.org>
|
||||
* Copyright (c) 2013, Markus Friedl <markus@openbsd.org>
|
||||
* Copyright (c) 2014, Theo de Raadt <deraadt@openbsd.org>
|
||||
* Copyright (c) 2015, Sudhi Herle <sudhi@herle.net>
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
// MP support header
|
||||
#include "MacportsLegacySupport.h"
|
||||
#if __MP_LEGACY_SUPPORT_ARC4RANDOM__
|
||||
|
||||
/*
|
||||
* ChaCha based random number generator from OpenBSD.
|
||||
*
|
||||
* Made fully portable and thread-safe by Sudhi Herle.
|
||||
*/
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <limits.h>
|
||||
#include <signal.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/random.h>
|
||||
#include <assert.h>
|
||||
#include <pthread.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
|
||||
#define ARC4R_KEYSZ 32
|
||||
#define ARC4R_IVSZ 8
|
||||
#define ARC4R_BLOCKSZ 64
|
||||
#define ARC4R_RSBUFSZ (16*ARC4R_BLOCKSZ)
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t input[16]; /* could be compressed */
|
||||
} chacha_ctx;
|
||||
|
||||
struct rand_state
|
||||
{
|
||||
size_t rs_have; /* valid bytes at end of rs_buf */
|
||||
size_t rs_count; /* bytes till reseed */
|
||||
pid_t rs_pid; /* My PID */
|
||||
chacha_ctx rs_chacha; /* chacha context for random keystream */
|
||||
u_char rs_buf[ARC4R_RSBUFSZ]; /* keystream blocks */
|
||||
};
|
||||
typedef struct rand_state rand_state;
|
||||
|
||||
#define KEYSTREAM_ONLY
|
||||
|
||||
typedef unsigned char u8;
|
||||
typedef uint32_t u32;
|
||||
|
||||
|
||||
#define U8C(v) (v##U)
|
||||
#define U32C(v) (v##U)
|
||||
|
||||
#define U8V(v) ((u8)(v) & U8C(0xFF))
|
||||
#define U32V(v) ((u32)(v) & U32C(0xFFFFFFFF))
|
||||
|
||||
#define ROTL32(v, n) \
|
||||
(U32V((v) << (n)) | ((v) >> (32 - (n))))
|
||||
|
||||
#define U8TO32_LITTLE(p) \
|
||||
(((u32)((p)[0]) ) | \
|
||||
((u32)((p)[1]) << 8) | \
|
||||
((u32)((p)[2]) << 16) | \
|
||||
((u32)((p)[3]) << 24))
|
||||
|
||||
#define U32TO8_LITTLE(p, v) \
|
||||
do { \
|
||||
(p)[0] = U8V((v) ); \
|
||||
(p)[1] = U8V((v) >> 8); \
|
||||
(p)[2] = U8V((v) >> 16); \
|
||||
(p)[3] = U8V((v) >> 24); \
|
||||
} while (0)
|
||||
|
||||
#define ROTATE(v,c) (ROTL32(v,c))
|
||||
#define XOR(v,w) ((v) ^ (w))
|
||||
#define PLUS(v,w) (U32V((v) + (w)))
|
||||
#define PLUSONE(v) (PLUS((v),1))
|
||||
|
||||
#define QUARTERROUND(a,b,c,d) \
|
||||
a = PLUS(a,b); d = ROTATE(XOR(d,a),16); \
|
||||
c = PLUS(c,d); b = ROTATE(XOR(b,c),12); \
|
||||
a = PLUS(a,b); d = ROTATE(XOR(d,a), 8); \
|
||||
c = PLUS(c,d); b = ROTATE(XOR(b,c), 7);
|
||||
|
||||
static const char sigma[16] = "expand 32-byte k";
|
||||
static const char tau[16] = "expand 16-byte k";
|
||||
|
||||
static void
|
||||
_chacha_keysetup(chacha_ctx *x,const u8 *k,u32 kbits,u32 ivbits)
|
||||
{
|
||||
const char *constants;
|
||||
|
||||
(void)ivbits;
|
||||
|
||||
x->input[4] = U8TO32_LITTLE(k + 0);
|
||||
x->input[5] = U8TO32_LITTLE(k + 4);
|
||||
x->input[6] = U8TO32_LITTLE(k + 8);
|
||||
x->input[7] = U8TO32_LITTLE(k + 12);
|
||||
if (kbits == 256) { /* recommended */
|
||||
k += 16;
|
||||
constants = sigma;
|
||||
} else { /* kbits == 128 */
|
||||
constants = tau;
|
||||
}
|
||||
x->input[8] = U8TO32_LITTLE(k + 0);
|
||||
x->input[9] = U8TO32_LITTLE(k + 4);
|
||||
x->input[10] = U8TO32_LITTLE(k + 8);
|
||||
x->input[11] = U8TO32_LITTLE(k + 12);
|
||||
x->input[0] = U8TO32_LITTLE(constants + 0);
|
||||
x->input[1] = U8TO32_LITTLE(constants + 4);
|
||||
x->input[2] = U8TO32_LITTLE(constants + 8);
|
||||
x->input[3] = U8TO32_LITTLE(constants + 12);
|
||||
}
|
||||
|
||||
static void
|
||||
_chacha_ivsetup(chacha_ctx *x,const u8 *iv)
|
||||
{
|
||||
x->input[12] = 0;
|
||||
x->input[13] = 0;
|
||||
x->input[14] = U8TO32_LITTLE(iv + 0);
|
||||
x->input[15] = U8TO32_LITTLE(iv + 4);
|
||||
}
|
||||
|
||||
static void
|
||||
_chacha_encrypt_bytes(chacha_ctx *x,const u8 *m,u8 *c,u32 bytes)
|
||||
{
|
||||
u32 x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15;
|
||||
u32 j0, j1, j2, j3, j4, j5, j6, j7, j8, j9, j10, j11, j12, j13, j14, j15;
|
||||
u8 *ctarget = NULL;
|
||||
u8 tmp[64];
|
||||
u_int i;
|
||||
|
||||
if (!bytes) return;
|
||||
|
||||
j0 = x->input[0];
|
||||
j1 = x->input[1];
|
||||
j2 = x->input[2];
|
||||
j3 = x->input[3];
|
||||
j4 = x->input[4];
|
||||
j5 = x->input[5];
|
||||
j6 = x->input[6];
|
||||
j7 = x->input[7];
|
||||
j8 = x->input[8];
|
||||
j9 = x->input[9];
|
||||
j10 = x->input[10];
|
||||
j11 = x->input[11];
|
||||
j12 = x->input[12];
|
||||
j13 = x->input[13];
|
||||
j14 = x->input[14];
|
||||
j15 = x->input[15];
|
||||
|
||||
for (;;) {
|
||||
if (bytes < 64) {
|
||||
for (i = 0;i < bytes;++i) tmp[i] = m[i];
|
||||
m = tmp;
|
||||
ctarget = c;
|
||||
c = tmp;
|
||||
}
|
||||
x0 = j0;
|
||||
x1 = j1;
|
||||
x2 = j2;
|
||||
x3 = j3;
|
||||
x4 = j4;
|
||||
x5 = j5;
|
||||
x6 = j6;
|
||||
x7 = j7;
|
||||
x8 = j8;
|
||||
x9 = j9;
|
||||
x10 = j10;
|
||||
x11 = j11;
|
||||
x12 = j12;
|
||||
x13 = j13;
|
||||
x14 = j14;
|
||||
x15 = j15;
|
||||
for (i = 20;i > 0;i -= 2) {
|
||||
QUARTERROUND( x0, x4, x8,x12)
|
||||
QUARTERROUND( x1, x5, x9,x13)
|
||||
QUARTERROUND( x2, x6,x10,x14)
|
||||
QUARTERROUND( x3, x7,x11,x15)
|
||||
QUARTERROUND( x0, x5,x10,x15)
|
||||
QUARTERROUND( x1, x6,x11,x12)
|
||||
QUARTERROUND( x2, x7, x8,x13)
|
||||
QUARTERROUND( x3, x4, x9,x14)
|
||||
}
|
||||
x0 = PLUS(x0,j0);
|
||||
x1 = PLUS(x1,j1);
|
||||
x2 = PLUS(x2,j2);
|
||||
x3 = PLUS(x3,j3);
|
||||
x4 = PLUS(x4,j4);
|
||||
x5 = PLUS(x5,j5);
|
||||
x6 = PLUS(x6,j6);
|
||||
x7 = PLUS(x7,j7);
|
||||
x8 = PLUS(x8,j8);
|
||||
x9 = PLUS(x9,j9);
|
||||
x10 = PLUS(x10,j10);
|
||||
x11 = PLUS(x11,j11);
|
||||
x12 = PLUS(x12,j12);
|
||||
x13 = PLUS(x13,j13);
|
||||
x14 = PLUS(x14,j14);
|
||||
x15 = PLUS(x15,j15);
|
||||
|
||||
#ifndef KEYSTREAM_ONLY
|
||||
x0 = XOR(x0,U8TO32_LITTLE(m + 0));
|
||||
x1 = XOR(x1,U8TO32_LITTLE(m + 4));
|
||||
x2 = XOR(x2,U8TO32_LITTLE(m + 8));
|
||||
x3 = XOR(x3,U8TO32_LITTLE(m + 12));
|
||||
x4 = XOR(x4,U8TO32_LITTLE(m + 16));
|
||||
x5 = XOR(x5,U8TO32_LITTLE(m + 20));
|
||||
x6 = XOR(x6,U8TO32_LITTLE(m + 24));
|
||||
x7 = XOR(x7,U8TO32_LITTLE(m + 28));
|
||||
x8 = XOR(x8,U8TO32_LITTLE(m + 32));
|
||||
x9 = XOR(x9,U8TO32_LITTLE(m + 36));
|
||||
x10 = XOR(x10,U8TO32_LITTLE(m + 40));
|
||||
x11 = XOR(x11,U8TO32_LITTLE(m + 44));
|
||||
x12 = XOR(x12,U8TO32_LITTLE(m + 48));
|
||||
x13 = XOR(x13,U8TO32_LITTLE(m + 52));
|
||||
x14 = XOR(x14,U8TO32_LITTLE(m + 56));
|
||||
x15 = XOR(x15,U8TO32_LITTLE(m + 60));
|
||||
#endif
|
||||
|
||||
j12 = PLUSONE(j12);
|
||||
if (!j12) {
|
||||
j13 = PLUSONE(j13);
|
||||
/* stopping at 2^70 bytes per nonce is user's responsibility */
|
||||
}
|
||||
|
||||
U32TO8_LITTLE(c + 0,x0);
|
||||
U32TO8_LITTLE(c + 4,x1);
|
||||
U32TO8_LITTLE(c + 8,x2);
|
||||
U32TO8_LITTLE(c + 12,x3);
|
||||
U32TO8_LITTLE(c + 16,x4);
|
||||
U32TO8_LITTLE(c + 20,x5);
|
||||
U32TO8_LITTLE(c + 24,x6);
|
||||
U32TO8_LITTLE(c + 28,x7);
|
||||
U32TO8_LITTLE(c + 32,x8);
|
||||
U32TO8_LITTLE(c + 36,x9);
|
||||
U32TO8_LITTLE(c + 40,x10);
|
||||
U32TO8_LITTLE(c + 44,x11);
|
||||
U32TO8_LITTLE(c + 48,x12);
|
||||
U32TO8_LITTLE(c + 52,x13);
|
||||
U32TO8_LITTLE(c + 56,x14);
|
||||
U32TO8_LITTLE(c + 60,x15);
|
||||
|
||||
if (bytes <= 64) {
|
||||
if (bytes < 64) {
|
||||
for (i = 0;i < bytes;++i) ctarget[i] = c[i];
|
||||
}
|
||||
x->input[12] = j12;
|
||||
x->input[13] = j13;
|
||||
return;
|
||||
}
|
||||
bytes -= 64;
|
||||
c += 64;
|
||||
#ifndef KEYSTREAM_ONLY
|
||||
m += 64;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#define minimum(a, b) ((a) < (b) ? (a) : (b))
|
||||
|
||||
#include "arc4random.h"
|
||||
|
||||
|
||||
static inline void
|
||||
_rs_init(rand_state* st, u8 *buf, size_t n)
|
||||
{
|
||||
assert(n >= (ARC4R_KEYSZ + ARC4R_IVSZ));
|
||||
|
||||
_chacha_keysetup(&st->rs_chacha, buf, ARC4R_KEYSZ * 8, 0);
|
||||
_chacha_ivsetup(&st->rs_chacha, buf + ARC4R_KEYSZ);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static inline void
|
||||
_rs_rekey(rand_state* st, u8 *dat, size_t datlen)
|
||||
{
|
||||
/* fill rs_buf with the keystream */
|
||||
_chacha_encrypt_bytes(&st->rs_chacha, st->rs_buf, st->rs_buf, sizeof st->rs_buf);
|
||||
|
||||
/* mix in optional user provided data */
|
||||
if (dat) {
|
||||
size_t i, m;
|
||||
|
||||
m = minimum(datlen, ARC4R_KEYSZ + ARC4R_IVSZ);
|
||||
for (i = 0; i < m; i++)
|
||||
st->rs_buf[i] ^= dat[i];
|
||||
|
||||
memset(dat, 0, datlen);
|
||||
}
|
||||
|
||||
/* immediately reinit for backtracking resistance */
|
||||
_rs_init(st, st->rs_buf, ARC4R_KEYSZ + ARC4R_IVSZ);
|
||||
memset(st->rs_buf, 0, ARC4R_KEYSZ + ARC4R_IVSZ);
|
||||
st->rs_have = (sizeof st->rs_buf) - ARC4R_KEYSZ - ARC4R_IVSZ;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
_rs_stir(rand_state* st)
|
||||
{
|
||||
u8 rnd[ARC4R_KEYSZ + ARC4R_IVSZ];
|
||||
|
||||
|
||||
int r = getentropy(rnd, sizeof rnd);
|
||||
assert(r == 0);
|
||||
|
||||
_rs_rekey(st, rnd, sizeof(rnd));
|
||||
|
||||
/* invalidate rs_buf */
|
||||
st->rs_have = 0;
|
||||
memset(st->rs_buf, 0, sizeof st->rs_buf);
|
||||
|
||||
st->rs_count = 1600000;
|
||||
}
|
||||
|
||||
|
||||
static inline void
|
||||
_rs_stir_if_needed(rand_state* st, size_t len)
|
||||
{
|
||||
if (st->rs_count <= len)
|
||||
_rs_stir(st);
|
||||
|
||||
st->rs_count -= len;
|
||||
}
|
||||
|
||||
|
||||
static inline void
|
||||
_rs_random_buf(rand_state* rs, void *_buf, size_t n)
|
||||
{
|
||||
u8 *buf = (u8 *)_buf;
|
||||
u8 *keystream;
|
||||
size_t m;
|
||||
|
||||
_rs_stir_if_needed(rs, n);
|
||||
while (n > 0) {
|
||||
if (rs->rs_have > 0) {
|
||||
m = minimum(n, rs->rs_have);
|
||||
keystream = rs->rs_buf + sizeof(rs->rs_buf) - rs->rs_have;
|
||||
memcpy(buf, keystream, m);
|
||||
memset(keystream, 0, m);
|
||||
buf += m;
|
||||
n -= m;
|
||||
rs->rs_have -= m;
|
||||
} else
|
||||
_rs_rekey(rs, NULL, 0);
|
||||
}
|
||||
}
|
||||
|
||||
static inline uint32_t
|
||||
_rs_random_u32(rand_state* rs)
|
||||
{
|
||||
u8 *keystream;
|
||||
uint32_t val;
|
||||
|
||||
_rs_stir_if_needed(rs, sizeof(val));
|
||||
if (rs->rs_have < sizeof(val))
|
||||
_rs_rekey(rs, NULL, 0);
|
||||
keystream = rs->rs_buf + sizeof(rs->rs_buf) - rs->rs_have;
|
||||
memcpy(&val, keystream, sizeof(val));
|
||||
memset(keystream, 0, sizeof(val));
|
||||
rs->rs_have -= sizeof(val);
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
|
||||
#if defined(__Darwin__) || defined(__APPLE__)
|
||||
|
||||
/*
|
||||
* Multi-threaded support using pthread API. Needed for OS X:
|
||||
*
|
||||
* https://www.reddit.com/r/cpp/comments/3bg8jc/anyone_know_if_and_when_applexcode_will_support/
|
||||
*/
|
||||
static pthread_key_t Rkey;
|
||||
static pthread_once_t Ronce = PTHREAD_ONCE_INIT;
|
||||
static volatile uint32_t Rforked = 0;
|
||||
|
||||
/*
|
||||
* Fork handler to reset my context
|
||||
*/
|
||||
static void
|
||||
_atfork()
|
||||
{
|
||||
// the pthread_atfork() callbacks called once per process.
|
||||
// We set it to be called by the child process.
|
||||
Rforked++;
|
||||
}
|
||||
|
||||
/*
|
||||
* Run once and only once by pthread lib. We use the opportunity to
|
||||
* create the thread-specific key.
|
||||
*/
|
||||
static void
|
||||
_screate()
|
||||
{
|
||||
pthread_key_create(&Rkey, 0);
|
||||
pthread_atfork(0, 0, _atfork);
|
||||
|
||||
/*
|
||||
* Get entropy once to initialize the fd - for non OpenBSD
|
||||
* systems.
|
||||
*/
|
||||
uint8_t buf[8];
|
||||
getentropy(buf, sizeof buf);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Get the per-thread rand state. Initialize if needed.
|
||||
*/
|
||||
static rand_state*
|
||||
_sget()
|
||||
{
|
||||
pthread_once(&Ronce, _screate);
|
||||
|
||||
volatile pthread_key_t* k = &Rkey;
|
||||
rand_state * z = (rand_state *)pthread_getspecific(*k);
|
||||
if (!z) {
|
||||
z = (rand_state*)calloc(sizeof *z, 1);
|
||||
assert(z);
|
||||
|
||||
_rs_stir(z);
|
||||
z->rs_pid = getpid();
|
||||
|
||||
pthread_setspecific(*k, z);
|
||||
}
|
||||
|
||||
/* Detect if a fork has happened */
|
||||
if (Rforked > 0 || getpid() != z->rs_pid) {
|
||||
Rforked = 0;
|
||||
z->rs_pid = getpid();
|
||||
_rs_stir(z);
|
||||
}
|
||||
|
||||
return z;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
/*
|
||||
* Use gcc extension to declare a thread-local variable.
|
||||
*
|
||||
* On most systems (including x86_64), thread-local access is
|
||||
* essentially free for non .so use cases.
|
||||
*
|
||||
*/
|
||||
static __thread rand_state st = { .rs_count = 0, .rs_pid = 0 };
|
||||
static inline rand_state*
|
||||
_sget()
|
||||
{
|
||||
rand_state* s = &st;
|
||||
|
||||
if (s->rs_count == 0 || getpid() != s->rs_pid) {
|
||||
_rs_stir(s);
|
||||
s->rs_pid = getpid();
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
#endif /* __Darwin__ */
|
||||
|
||||
|
||||
/*
|
||||
* Public API.
|
||||
*/
|
||||
|
||||
|
||||
void
|
||||
arc4random_buf(void* b, size_t n)
|
||||
{
|
||||
rand_state* z = _sget();
|
||||
|
||||
_rs_random_buf(z, b, n);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Calculate a uniformly distributed random number less than upper_bound
|
||||
* avoiding "modulo bias".
|
||||
*
|
||||
* Uniformity is achieved by generating new random numbers until the one
|
||||
* returned is outside the range [0, 2**32 % upper_bound). This
|
||||
* guarantees the selected random number will be inside
|
||||
* [2**32 % upper_bound, 2**32) which maps back to [0, upper_bound)
|
||||
* after reduction modulo upper_bound.
|
||||
*/
|
||||
uint32_t
|
||||
arc4random_uniform(uint32_t upper_bound)
|
||||
{
|
||||
rand_state* z = _sget();
|
||||
uint32_t r, min;
|
||||
|
||||
if (upper_bound < 2)
|
||||
return 0;
|
||||
|
||||
/* 2**32 % x == (2**32 - x) % x */
|
||||
min = -upper_bound % upper_bound;
|
||||
|
||||
/*
|
||||
* This could theoretically loop forever but each retry has
|
||||
* p > 0.5 (worst case, usually far better) of selecting a
|
||||
* number inside the range we need, so it should rarely need
|
||||
* to re-roll.
|
||||
*/
|
||||
for (;;) {
|
||||
r = _rs_random_u32(z);
|
||||
if (r >= min)
|
||||
break;
|
||||
}
|
||||
|
||||
return r % upper_bound;
|
||||
}
|
||||
|
||||
|
||||
#endif /* __MP_LEGACY_SUPPORT_ARC4RANDOM__ */
|
49
extern/macports-legacy-support/src/arc4random.h
vendored
Normal file
49
extern/macports-legacy-support/src/arc4random.h
vendored
Normal file
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
* Copyright (c) 1996, David Mazieres <dm@uun.org>
|
||||
* Copyright (c) 2008, Damien Miller <djm@openbsd.org>
|
||||
* Copyright (c) 2013, Markus Friedl <markus@openbsd.org>
|
||||
* Copyright (c) 2014, Theo de Raadt <deraadt@openbsd.org>
|
||||
* Copyright (c) 2015, Sudhi Herle <sudhi@herle.net>
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef ___ARC4RANDOM_H_5000666_1462841354__
|
||||
#define ___ARC4RANDOM_H_5000666_1462841354__ 1
|
||||
|
||||
/* Provide C linkage for symbols declared here .. */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#include <stdint.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
/*
|
||||
* Generate and return a uniformly random 32-bit quantity with an
|
||||
* upper bound of 'upper_bound'
|
||||
*/
|
||||
extern uint32_t arc4random_uniform(uint32_t upper_bound);
|
||||
|
||||
/*
|
||||
* Generate 'n' random bytes and put them in 'buf'.
|
||||
*/
|
||||
extern void arc4random_buf(void* buf, size_t n);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* ! ___ARC4RANDOM_H_5000666_1462841354__ */
|
||||
|
||||
/* EOF */
|
81
extern/macports-legacy-support/src/dirfuncs_compat.c
vendored
Normal file
81
extern/macports-legacy-support/src/dirfuncs_compat.c
vendored
Normal file
|
@ -0,0 +1,81 @@
|
|||
/*
|
||||
* Copyright (c) 2024 Frederick H. G. Wright II <fw@fwright.net>
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Earlier versions of legacy-support needed wrappers around several OS
|
||||
* calls related to directories, in order to implement fdopendir(). That
|
||||
* is no longer the case, but existing dependents still reference those
|
||||
* wrapper calls. For compatibility, we continue to provide those functions,
|
||||
* but just as transparent wrappers around the OS calls.
|
||||
*
|
||||
* These wrappers can eventually be removed once all dependents have been
|
||||
* rebuilt with the current headers. But since there would be significant
|
||||
* work in determining when this is the case, and since they only add 752
|
||||
* bytes to the library size, they should probably be left in place for a
|
||||
* long time.
|
||||
*
|
||||
* This is only relevant for OS versions where our fdopendir() is needed,
|
||||
* hence the conditional (which is the same conditional as was used for
|
||||
* the earlier implementations).
|
||||
*/
|
||||
|
||||
/* MP support header */
|
||||
#include "MacportsLegacySupport.h"
|
||||
#if __MP_LEGACY_SUPPORT_FDOPENDIR__
|
||||
|
||||
#include "dirfuncs_compat.h"
|
||||
|
||||
DIR *
|
||||
__mpls_opendir(const char *filename) {
|
||||
return opendir(filename);
|
||||
}
|
||||
|
||||
struct dirent *
|
||||
__mpls_readdir(DIR *dirp) {
|
||||
return readdir(dirp);
|
||||
}
|
||||
|
||||
int
|
||||
__mpls_readdir_r(DIR *dirp, struct dirent *entry, struct dirent **result) {
|
||||
return readdir_r(dirp, entry, result);
|
||||
}
|
||||
|
||||
long
|
||||
__mpls_telldir(DIR *dirp) {
|
||||
return telldir(dirp);
|
||||
}
|
||||
|
||||
void
|
||||
__mpls_seekdir(DIR *dirp, long loc) {
|
||||
seekdir(dirp, loc);
|
||||
}
|
||||
|
||||
void
|
||||
__mpls_rewinddir(DIR *dirp) {
|
||||
rewinddir(dirp);
|
||||
}
|
||||
|
||||
int
|
||||
__mpls_closedir(DIR *dirp) {
|
||||
return closedir(dirp);
|
||||
}
|
||||
|
||||
int
|
||||
__mpls_dirfd(DIR *dirp) {
|
||||
return dirfd(dirp);
|
||||
}
|
||||
|
||||
#endif /* __MP_LEGACY_SUPPORT_FDOPENDIR__ */
|
48
extern/macports-legacy-support/src/dirfuncs_compat.h
vendored
Normal file
48
extern/macports-legacy-support/src/dirfuncs_compat.h
vendored
Normal file
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* Copyright (c) 2024 Frederick H. G. Wright II <fw@fwright.net>
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* Prototypes for directory function compatibility wrappers */
|
||||
|
||||
#ifndef __MP_LEGACY_SUPPORT_DIRFUNCS_COMPAT_H
|
||||
#define __MP_LEGACY_SUPPORT_DIRFUNCS_COMPAT_H
|
||||
|
||||
#include <dirent.h>
|
||||
|
||||
DIR *
|
||||
__mpls_opendir(const char *filename);
|
||||
|
||||
struct dirent *
|
||||
__mpls_readdir(DIR *dirp);
|
||||
|
||||
int
|
||||
__mpls_readdir_r(DIR *dirp, struct dirent *entry, struct dirent **result);
|
||||
|
||||
long
|
||||
__mpls_telldir(DIR *dirp);
|
||||
|
||||
void
|
||||
__mpls_seekdir(DIR *dirp, long loc);
|
||||
|
||||
void
|
||||
__mpls_rewinddir(DIR *dirp);
|
||||
|
||||
int
|
||||
__mpls_closedir(DIR *dirp);
|
||||
|
||||
int
|
||||
__mpls_dirfd(DIR *dirp);
|
||||
|
||||
#endif /* __MP_LEGACY_SUPPORT_DIRFUNCS_COMPAT_H */
|
39
extern/macports-legacy-support/src/dprintf.c
vendored
Normal file
39
extern/macports-legacy-support/src/dprintf.c
vendored
Normal file
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* Copyright (c) 2021, Evan Miller <emmiller@gmail.com>
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
// MP support header
|
||||
#include "MacportsLegacySupport.h"
|
||||
#if __MP_LEGACY_SUPPORT_DPRINTF__
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/errno.h>
|
||||
|
||||
int dprintf(int fildes, const char * __restrict format, ...) {
|
||||
FILE *stream = fdopen(fildes, "w");
|
||||
if (stream == NULL) {
|
||||
errno = EBADF;
|
||||
return -1;
|
||||
}
|
||||
va_list ap;
|
||||
va_start(ap, format);
|
||||
int result = vfprintf(stream, format, ap);
|
||||
va_end(ap);
|
||||
fclose(stream);
|
||||
return result;
|
||||
}
|
||||
|
||||
#endif /* __MP_LEGACY_SUPPORT_DPRINTF__ */
|
262
extern/macports-legacy-support/src/fmemopen.c
vendored
Normal file
262
extern/macports-legacy-support/src/fmemopen.c
vendored
Normal file
|
@ -0,0 +1,262 @@
|
|||
/*-
|
||||
* Copyright (C) 2013 Pietro Cerutti <gahr@FreeBSD.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
extern int __sflags(const char *, int *);
|
||||
|
||||
struct fmemopen_cookie
|
||||
{
|
||||
char *buf; /* pointer to the memory region */
|
||||
bool own; /* did we allocate the buffer ourselves? */
|
||||
char bin; /* is this a binary buffer? */
|
||||
size_t size; /* buffer length in bytes */
|
||||
size_t len; /* data length in bytes */
|
||||
size_t off; /* current offset into the buffer */
|
||||
};
|
||||
|
||||
static int fmemopen_read(void *cookie, char *buf, int nbytes);
|
||||
static int fmemopen_write(void *cookie, const char *buf, int nbytes);
|
||||
static fpos_t fmemopen_seek(void *cookie, fpos_t offset, int whence);
|
||||
static int fmemopen_close(void *cookie);
|
||||
|
||||
FILE *
|
||||
fmemopen(void * __restrict buf, size_t size, const char * __restrict mode)
|
||||
{
|
||||
struct fmemopen_cookie *ck;
|
||||
FILE *f;
|
||||
int flags, rc;
|
||||
|
||||
/*
|
||||
* POSIX says we shall return EINVAL if size is 0.
|
||||
*/
|
||||
if (size == 0) {
|
||||
errno = EINVAL;
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Retrieve the flags as used by open(2) from the mode argument, and
|
||||
* validate them.
|
||||
*/
|
||||
rc = __sflags(mode, &flags);
|
||||
if (rc == 0) {
|
||||
errno = EINVAL;
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* There's no point in requiring an automatically allocated buffer
|
||||
* in write-only mode.
|
||||
*/
|
||||
if (!(flags & O_RDWR) && buf == NULL) {
|
||||
errno = EINVAL;
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
ck = malloc(sizeof(struct fmemopen_cookie));
|
||||
if (ck == NULL) {
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
ck->off = 0;
|
||||
ck->size = size;
|
||||
|
||||
/* Check whether we have to allocate the buffer ourselves. */
|
||||
ck->own = ((ck->buf = buf) == NULL);
|
||||
if (ck->own) {
|
||||
ck->buf = malloc(size);
|
||||
if (ck->buf == NULL) {
|
||||
free(ck);
|
||||
return (NULL);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* POSIX distinguishes between w+ and r+, in that w+ is supposed to
|
||||
* truncate the buffer.
|
||||
*/
|
||||
if (ck->own || mode[0] == 'w') {
|
||||
ck->buf[0] = '\0';
|
||||
}
|
||||
|
||||
/* Check for binary mode. */
|
||||
ck->bin = strchr(mode, 'b') != NULL;
|
||||
|
||||
/*
|
||||
* The size of the current buffer contents is set depending on the
|
||||
* mode:
|
||||
*
|
||||
* for append (text-mode), the position of the first NULL byte, or the
|
||||
* size of the buffer if none is found
|
||||
*
|
||||
* for append (binary-mode), the size of the buffer
|
||||
*
|
||||
* for read, the size of the buffer
|
||||
*
|
||||
* for write, 0
|
||||
*/
|
||||
switch (mode[0]) {
|
||||
case 'a':
|
||||
ck->off = ck->len = strnlen(ck->buf, ck->size);
|
||||
break;
|
||||
case 'r':
|
||||
ck->len = size;
|
||||
break;
|
||||
case 'w':
|
||||
ck->len = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
f = funopen(ck,
|
||||
flags & O_WRONLY ? NULL : fmemopen_read,
|
||||
flags & O_RDONLY ? NULL : fmemopen_write,
|
||||
fmemopen_seek, fmemopen_close);
|
||||
|
||||
if (f == NULL) {
|
||||
if (ck->own)
|
||||
free(ck->buf);
|
||||
free(ck);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
if (mode[0] == 'a')
|
||||
f->_flags |= __SAPP;
|
||||
|
||||
/*
|
||||
* Turn off buffering, so a write past the end of the buffer
|
||||
* correctly returns a short object count.
|
||||
*/
|
||||
setvbuf(f, NULL, _IONBF, 0);
|
||||
|
||||
return (f);
|
||||
}
|
||||
|
||||
static int
|
||||
fmemopen_read(void *cookie, char *buf, int nbytes)
|
||||
{
|
||||
struct fmemopen_cookie *ck = cookie;
|
||||
|
||||
if (nbytes > ck->len - ck->off)
|
||||
nbytes = ck->len - ck->off;
|
||||
|
||||
if (nbytes == 0)
|
||||
return (0);
|
||||
|
||||
memcpy(buf, ck->buf + ck->off, nbytes);
|
||||
|
||||
ck->off += nbytes;
|
||||
|
||||
return (nbytes);
|
||||
}
|
||||
|
||||
static int
|
||||
fmemopen_write(void *cookie, const char *buf, int nbytes)
|
||||
{
|
||||
struct fmemopen_cookie *ck = cookie;
|
||||
|
||||
if (nbytes > ck->size - ck->off)
|
||||
nbytes = ck->size - ck->off;
|
||||
|
||||
if (nbytes == 0)
|
||||
return (0);
|
||||
|
||||
memcpy(ck->buf + ck->off, buf, nbytes);
|
||||
|
||||
ck->off += nbytes;
|
||||
|
||||
if (ck->off > ck->len)
|
||||
ck->len = ck->off;
|
||||
|
||||
/*
|
||||
* We append a NULL byte if all these conditions are met:
|
||||
* - the buffer is not binary
|
||||
* - the buffer is not full
|
||||
* - the data just written doesn't already end with a NULL byte
|
||||
*/
|
||||
if (!ck->bin && ck->off < ck->size && ck->buf[ck->off - 1] != '\0')
|
||||
ck->buf[ck->off] = '\0';
|
||||
|
||||
return (nbytes);
|
||||
}
|
||||
|
||||
static fpos_t
|
||||
fmemopen_seek(void *cookie, fpos_t offset, int whence)
|
||||
{
|
||||
struct fmemopen_cookie *ck = cookie;
|
||||
|
||||
|
||||
switch (whence) {
|
||||
case SEEK_SET:
|
||||
if (offset > ck->size) {
|
||||
errno = EINVAL;
|
||||
return (-1);
|
||||
}
|
||||
ck->off = offset;
|
||||
break;
|
||||
|
||||
case SEEK_CUR:
|
||||
if (ck->off + offset > ck->size) {
|
||||
errno = EINVAL;
|
||||
return (-1);
|
||||
}
|
||||
ck->off += offset;
|
||||
break;
|
||||
|
||||
case SEEK_END:
|
||||
if (offset > 0 || -offset > ck->len) {
|
||||
errno = EINVAL;
|
||||
return (-1);
|
||||
}
|
||||
ck->off = ck->len + offset;
|
||||
break;
|
||||
|
||||
default:
|
||||
errno = EINVAL;
|
||||
return (-1);
|
||||
}
|
||||
|
||||
return (ck->off);
|
||||
}
|
||||
|
||||
static int
|
||||
fmemopen_close(void *cookie)
|
||||
{
|
||||
struct fmemopen_cookie *ck = cookie;
|
||||
|
||||
if (ck->own)
|
||||
free(ck->buf);
|
||||
|
||||
free(ck);
|
||||
|
||||
return (0);
|
||||
}
|
77
extern/macports-legacy-support/src/fsetattrlist.c
vendored
Normal file
77
extern/macports-legacy-support/src/fsetattrlist.c
vendored
Normal file
|
@ -0,0 +1,77 @@
|
|||
/*
|
||||
* Copyright (c) 2021 Mihai Moldovan <ionic@ionic.de>
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* MP support header */
|
||||
#include "MacportsLegacySupport.h"
|
||||
#if __MP_LEGACY_SUPPORT_FSETATTRLIST__
|
||||
|
||||
#include <sys/attr.h>
|
||||
#include <sys/fcntl.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/errno.h>
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
||||
#ifdef __LP64__
|
||||
int fsetattrlist(int fd, void *a, void *buf, size_t size, unsigned int flags)
|
||||
#else /* defined (__LP64__) */
|
||||
int fsetattrlist(int fd, void *a, void *buf, size_t size, unsigned long flags)
|
||||
#endif /* defined (__LP64__) */
|
||||
{
|
||||
int cont = 1,
|
||||
ret = 0;
|
||||
|
||||
char fpath[MAXPATHLEN];
|
||||
memset (fpath, 0, MAXPATHLEN);
|
||||
if (-1 == fcntl(fd, F_GETPATH, fpath)) {
|
||||
ret = EBADF;
|
||||
cont = 0;
|
||||
}
|
||||
|
||||
#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1080
|
||||
/*
|
||||
* Older systems don't correctly check if no attributes are to be set, which usually
|
||||
* means a buffer size of zero and return an error since they malloc a block of
|
||||
* memory with size zero, leading to ENOMEM.
|
||||
*
|
||||
* Emulate the fix from 10.8 for those.
|
||||
*/
|
||||
const struct attrlist *al = a;
|
||||
if (al->commonattr == 0 &&
|
||||
(al->volattr & ~ATTR_VOL_INFO) == 0 &&
|
||||
al->dirattr == 0 &&
|
||||
al->fileattr == 0 &&
|
||||
al->forkattr == 0) {
|
||||
cont = 0;
|
||||
|
||||
/*
|
||||
* Explicitly let the potential error from above pass through, since that's what
|
||||
* the original function seems to do as well.
|
||||
*/
|
||||
}
|
||||
#endif
|
||||
|
||||
if (cont) {
|
||||
ret = setattrlist(fpath, a, buf, size, flags);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif /* __MP_LEGACY_SUPPORT_FSETATTRLIST__ */
|
80
extern/macports-legacy-support/src/fsgetpath.c
vendored
Normal file
80
extern/macports-legacy-support/src/fsgetpath.c
vendored
Normal file
|
@ -0,0 +1,80 @@
|
|||
/*
|
||||
* Copyright (c) 2019
|
||||
* from an example posted in Apple Developer Support
|
||||
* https://forums.developer.apple.com/thread/103162
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
// MP support header
|
||||
#include "MacportsLegacySupport.h"
|
||||
#if __MP_LEGACY_SUPPORT_FSGETPATH__
|
||||
|
||||
|
||||
#if 1
|
||||
/* SYS_fsgetpath is only available on 10.6 and up */
|
||||
#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
|
||||
/* implement using a syscall available macOS 10.6 to 10.12 */
|
||||
/* this should be thoroughly vetted as a syscall, but is private API */
|
||||
#include <unistd.h>
|
||||
#include <sys/syscall.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/mount.h>
|
||||
ssize_t fsgetpath(char * buf, size_t buflen, fsid_t * fsid, uint64_t obj_id) {
|
||||
return (ssize_t)syscall(SYS_fsgetpath, buf, (size_t)buflen, fsid, (uint64_t)obj_id);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
/* implement with a compatability function that presently compiles on 10.6 and over */
|
||||
/* this may be better (see linked post above) but it's hard to thoroughly test it. */
|
||||
/* this may also be able to be expanded to cover 10.4 and 10.5 if we can workaround ATTR_CMN_FULLPATH */
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <getopt.h>
|
||||
#include <sys/attr.h>
|
||||
#include <sys/mount.h>
|
||||
|
||||
ssize_t fsgetpath(char * buf, size_t buflen, fsid_t * fsid, uint64_t obj_id) {
|
||||
char volfsPath[64]; // 8 for `/.vol//\0`, 10 for `fsid->val[0]`, 20 for `obj_id`, rounded up for paranoia
|
||||
|
||||
snprintf(volfsPath, sizeof(volfsPath), "/.vol/%ld/%llu", (long) fsid->val[0], (unsigned long long) obj_id);
|
||||
|
||||
struct {
|
||||
uint32_t length;
|
||||
attrreference_t pathRef;
|
||||
char buffer[MAXPATHLEN];
|
||||
} __attribute__((aligned(4), packed)) attrBuf;
|
||||
|
||||
struct attrlist attrList;
|
||||
memset(&attrList, 0, sizeof(attrList));
|
||||
attrList.bitmapcount = ATTR_BIT_MAP_COUNT;
|
||||
attrList.commonattr = ATTR_CMN_FULLPATH;
|
||||
|
||||
int success = getattrlist(volfsPath, &attrList, &attrBuf, sizeof(attrBuf), 0) == 0;
|
||||
if ( ! success ) {
|
||||
return -1;
|
||||
}
|
||||
if (attrBuf.pathRef.attr_length > buflen) {
|
||||
errno = ENOSPC;
|
||||
return -1;
|
||||
}
|
||||
strlcpy(buf, ((const char *) &attrBuf.pathRef) + attrBuf.pathRef.attr_dataoffset, buflen);
|
||||
return attrBuf.pathRef.attr_length;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __MP_LEGACY_SUPPORT_FSGETPATH__ */
|
105
extern/macports-legacy-support/src/getdelim.c
vendored
Normal file
105
extern/macports-legacy-support/src/getdelim.c
vendored
Normal file
|
@ -0,0 +1,105 @@
|
|||
|
||||
/*-
|
||||
* Copyright (c) 2011 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Christos Zoulas.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
// MP support header
|
||||
#include "MacportsLegacySupport.h"
|
||||
#if __MP_LEGACY_SUPPORT_GETLINE__
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include "getdelim.h"
|
||||
|
||||
#include <limits.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
|
||||
#ifndef SIZE_MAX
|
||||
# define SIZE_MAX ((size_t) -1)
|
||||
#endif
|
||||
#ifndef SSIZE_MAX
|
||||
# define SSIZE_MAX ((ssize_t) (SIZE_MAX / 2))
|
||||
#endif
|
||||
#if !HAVE_FLOCKFILE
|
||||
# undef flockfile
|
||||
# define flockfile(x) ((void) 0)
|
||||
#endif
|
||||
#if !HAVE_FUNLOCKFILE
|
||||
# undef funlockfile
|
||||
# define funlockfile(x) ((void) 0)
|
||||
#endif
|
||||
|
||||
/* Read up to (and including) a DELIMITER from FP into *LINEPTR (and
|
||||
NUL-terminate it). *LINEPTR is a pointer returned from malloc (or
|
||||
NULL), pointing to *N characters of space. It is realloc'ed as
|
||||
necessary. Returns the number of characters read (not including
|
||||
the null terminator), or -1 on error or EOF. */
|
||||
|
||||
ssize_t
|
||||
getdelim(char **buf, size_t *bufsiz, int delimiter, FILE *fp)
|
||||
{
|
||||
char *ptr, *eptr;
|
||||
|
||||
|
||||
if (*buf == NULL || *bufsiz == 0) {
|
||||
*bufsiz = BUFSIZ;
|
||||
if ((*buf = malloc(*bufsiz)) == NULL)
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (ptr = *buf, eptr = *buf + *bufsiz;;) {
|
||||
int c = fgetc(fp);
|
||||
if (c == -1) {
|
||||
if (feof(fp))
|
||||
return ptr == *buf ? -1 : ptr - *buf;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
*ptr++ = c;
|
||||
if (c == delimiter) {
|
||||
*ptr = '\0';
|
||||
return ptr - *buf;
|
||||
}
|
||||
if (ptr + 2 >= eptr) {
|
||||
char *nbuf;
|
||||
size_t nbufsiz = *bufsiz * 2;
|
||||
ssize_t d = ptr - *buf;
|
||||
if ((nbuf = realloc(*buf, nbufsiz)) == NULL)
|
||||
return -1;
|
||||
*buf = nbuf;
|
||||
*bufsiz = nbufsiz;
|
||||
eptr = nbuf + nbufsiz;
|
||||
ptr = nbuf + d;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
37
extern/macports-legacy-support/src/getdelim.h
vendored
Normal file
37
extern/macports-legacy-support/src/getdelim.h
vendored
Normal file
|
@ -0,0 +1,37 @@
|
|||
|
||||
/*
|
||||
* Copyright (c) Ian F. Darwin 1986-1995.
|
||||
* Software written by Ian F. Darwin and others;
|
||||
* maintained 1995-present by Christos Zoulas and others.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice immediately at the beginning of the file, without modification,
|
||||
* this list of conditions, and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/* Get size_t, FILE, ssize_t. And getdelim, if available. */
|
||||
# include <stddef.h>
|
||||
# include <stdio.h>
|
||||
# include <sys/types.h>
|
||||
|
||||
#if !HAVE_DECL_GETDELIM
|
||||
ssize_t getdelim(char **dst, size_t *len, int delimiter, FILE *fp);
|
||||
#endif /* !HAVE_GETDELIM */
|
89
extern/macports-legacy-support/src/getentropy.c
vendored
Normal file
89
extern/macports-legacy-support/src/getentropy.c
vendored
Normal file
|
@ -0,0 +1,89 @@
|
|||
|
||||
/*
|
||||
* Copyright (c) 2021
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
// MP support header
|
||||
#include "MacportsLegacySupport.h"
|
||||
#if __MP_LEGACY_SUPPORT_GETENTROPY__
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/random.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <errno.h>
|
||||
|
||||
void
|
||||
_error(int doexit, int err, const char* fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
fflush(stdout);
|
||||
fflush(stderr);
|
||||
va_start(ap, fmt);
|
||||
vfprintf(stderr, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
if (err > 0)
|
||||
fprintf(stderr, "\n %s (Errno %d)\n", strerror(err), err);
|
||||
|
||||
if (doexit) {
|
||||
fflush(stderr);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
_randopen(const char* name)
|
||||
{
|
||||
int fd = open(name, O_RDONLY);
|
||||
if (fd < 0) {
|
||||
_error(1, errno, "Cannot open system random number dev %s", name);
|
||||
}
|
||||
|
||||
return fd;
|
||||
}
|
||||
|
||||
int
|
||||
getentropy(void* buf, size_t n)
|
||||
{
|
||||
|
||||
static int fd = -1;
|
||||
uint8_t* b = (uint8_t*)buf;
|
||||
|
||||
if (fd < 0)
|
||||
fd = _randopen("/dev/urandom");
|
||||
|
||||
while (n > 0)
|
||||
{
|
||||
ssize_t m = (read)(fd, b, n);
|
||||
|
||||
if (m < 0) {
|
||||
if (errno == EINTR) continue;
|
||||
_error(1, errno, "Fatal read error while reading rand dev");
|
||||
}
|
||||
b += m;
|
||||
n -= m;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* __MP_LEGACY_SUPPORT_GETENTROPY__ */
|
48
extern/macports-legacy-support/src/getline.c
vendored
Normal file
48
extern/macports-legacy-support/src/getline.c
vendored
Normal file
|
@ -0,0 +1,48 @@
|
|||
|
||||
/*-
|
||||
* Copyright (c) 2011 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Christos Zoulas.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
// MP support header
|
||||
#include "MacportsLegacySupport.h"
|
||||
#if __MP_LEGACY_SUPPORT_GETLINE__
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include "getdelim.h"
|
||||
#include "getline.h"
|
||||
|
||||
ssize_t
|
||||
getline(char **buf, size_t *bufsiz, FILE *fp)
|
||||
{
|
||||
return getdelim(buf, bufsiz, '\n', fp);
|
||||
}
|
||||
|
||||
#endif /* __MP_LEGACY_SUPPORT_GETLINE__ */
|
37
extern/macports-legacy-support/src/getline.h
vendored
Normal file
37
extern/macports-legacy-support/src/getline.h
vendored
Normal file
|
@ -0,0 +1,37 @@
|
|||
|
||||
/*
|
||||
* Copyright (c) Ian F. Darwin 1986-1995.
|
||||
* Software written by Ian F. Darwin and others;
|
||||
* maintained 1995-present by Christos Zoulas and others.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice immediately at the beginning of the file, without modification,
|
||||
* this list of conditions, and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/* Get size_t, FILE, ssize_t. And getline, if available. */
|
||||
# include <stddef.h>
|
||||
# include <stdio.h>
|
||||
# include <sys/types.h>
|
||||
|
||||
#if !HAVE_DECL_GETLINE
|
||||
ssize_t getline(char **dst, size_t *len, FILE *fp);
|
||||
#endif /* !HAVE_GETLINE */
|
82
extern/macports-legacy-support/src/macports_legacy_atexit.c
vendored
Normal file
82
extern/macports-legacy-support/src/macports_legacy_atexit.c
vendored
Normal file
|
@ -0,0 +1,82 @@
|
|||
/*
|
||||
* Copyright (c) 2022
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* MP support header */
|
||||
#include "MacportsLegacySupport.h"
|
||||
|
||||
/* _tlv_atexit wrap */
|
||||
#if __MP_LEGACY_SUPPORT_ATEXIT_WRAP__
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <dlfcn.h>
|
||||
|
||||
/* signature from https://opensource.apple.com/source/dyld/dyld-852.2/src/threadLocalVariables.c.auto.html */
|
||||
void _tlv_atexit(void (*func)(void*), void* objAddr) {
|
||||
void (*real__tlv_atexit)(void (*func)(void*), void* objAddr);
|
||||
int (*real___cxa_thread_atexit)(void (*dtor)(void*), void* obj, void* dso_symbol);
|
||||
|
||||
real__tlv_atexit = dlsym(RTLD_NEXT, "_tlv_atexit");
|
||||
if (real__tlv_atexit != NULL) {
|
||||
/* _tlv_atexit exists in libSystem.B.dylib on 10.7 and later */
|
||||
real__tlv_atexit(func, objAddr);
|
||||
return;
|
||||
}
|
||||
|
||||
real___cxa_thread_atexit = dlsym(RTLD_DEFAULT, "__cxa_thread_atexit");
|
||||
if (real___cxa_thread_atexit != NULL) {
|
||||
/* __cxa_thread_atexit exists in
|
||||
MacPorts provided libc++ on 10.6 and earlier
|
||||
libSystem.B.dylib on 10.8 and later
|
||||
MacPorts provided libstdc++
|
||||
|
||||
in all cases, third parameter (dso_handle) seems to be ignored
|
||||
*/
|
||||
real___cxa_thread_atexit(func, objAddr, NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* signature from https://github.com/llvm-mirror/libcxxabi/blob/master/src/cxa_thread_atexit.cpp */
|
||||
int __cxa_thread_atexit(void (*dtor)(void*), void* obj, void* dso_symbol) {
|
||||
void (*real__tlv_atexit)(void (*func)(void*), void* objAddr);
|
||||
int (*real___cxa_thread_atexit)(void (*dtor)(void*), void* obj, void* dso_symbol);
|
||||
|
||||
real___cxa_thread_atexit = dlsym(RTLD_NEXT, "__cxa_thread_atexit");
|
||||
if (real___cxa_thread_atexit != NULL) {
|
||||
/* __cxa_thread_atexit exists in
|
||||
MacPorts provided libc++ on 10.6 and earlier
|
||||
libSystem.B.dylib on 10.8 and later
|
||||
MacPorts provided libstdc++
|
||||
*/
|
||||
return real___cxa_thread_atexit(dtor, obj, dso_symbol);
|
||||
}
|
||||
|
||||
real__tlv_atexit = dlsym(RTLD_DEFAULT, "_tlv_atexit");
|
||||
if (real__tlv_atexit != NULL) {
|
||||
/* _tlv_atexit exists in libSystem.B.dylib on 10.7 and later
|
||||
|
||||
it seems to be common practice to ignore dso_symbol
|
||||
*/
|
||||
real__tlv_atexit(dtor, obj);
|
||||
return 0;
|
||||
}
|
||||
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
#endif /*__MP_LEGACY_SUPPORT_ATEXIT_WRAP__*/
|
78
extern/macports-legacy-support/src/macports_legacy_copyfile.c
vendored
Normal file
78
extern/macports-legacy-support/src/macports_legacy_copyfile.c
vendored
Normal file
|
@ -0,0 +1,78 @@
|
|||
/*
|
||||
* Copyright (c) 2022
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* MP support header */
|
||||
#include "MacportsLegacySupport.h"
|
||||
|
||||
/* copyfile and its associated functions wrap */
|
||||
#if __MP_LEGACY_SUPPORT_COPYFILE_WRAP__
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <dlfcn.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <copyfile.h>
|
||||
|
||||
int copyfile_state_get(copyfile_state_t s, uint32_t flag, void * dst)
|
||||
{
|
||||
int (*real_copyfile_state_get)(copyfile_state_t s, uint32_t flag, void * dst);
|
||||
int ret;
|
||||
char *file_name;
|
||||
int file_descriptor;
|
||||
struct stat file_stat;
|
||||
|
||||
real_copyfile_state_get = dlsym(RTLD_NEXT, "copyfile_state_get");
|
||||
if (real_copyfile_state_get == NULL) {
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
switch(flag)
|
||||
{
|
||||
case COPYFILE_STATE_COPIED:
|
||||
/* since copyfile did not recored how many bytes were copied, return the size of the destination file */
|
||||
/* first check if the file descriptor has been set */
|
||||
ret = real_copyfile_state_get(s, COPYFILE_STATE_DST_FD, &file_descriptor);
|
||||
if ( ret < 0 ) {
|
||||
return ret;
|
||||
}
|
||||
if ( file_descriptor != -2 ) {
|
||||
ret = fstat(file_descriptor, &file_stat);
|
||||
return ret;
|
||||
} else {
|
||||
/* the file descriptor was not set, so check the file name */
|
||||
ret = real_copyfile_state_get(s, COPYFILE_STATE_DST_FILENAME, &file_name);
|
||||
if ( ret < 0 ) {
|
||||
return ret;
|
||||
}
|
||||
if ( file_name == NULL ) {
|
||||
/* neither the file descriptor nor the file name has been set */
|
||||
return real_copyfile_state_get(s, flag, dst);
|
||||
}
|
||||
ret = stat(file_name, &file_stat);
|
||||
}
|
||||
*(off_t*)dst = file_stat.st_size;
|
||||
return 0;
|
||||
break;
|
||||
case COPYFILE_STATE_STATUS_CB:
|
||||
case COPYFILE_STATE_STATUS_CTX:
|
||||
/* copyfile did not run the callback function, so return default (which is an error) */
|
||||
default:
|
||||
return real_copyfile_state_get(s, flag, dst);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* __MP_LEGACY_SUPPORT_COPYFILE_WRAP__ */
|
36
extern/macports-legacy-support/src/macports_legacy_os_unfair_lock.c
vendored
Normal file
36
extern/macports-legacy-support/src/macports_legacy_os_unfair_lock.c
vendored
Normal file
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* Copyright (c) 2023
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* MP support header */
|
||||
#include "MacportsLegacySupport.h"
|
||||
|
||||
#if __MP_LEGACY_SUPPORT_OS_UNFAIR_LOCK__
|
||||
|
||||
#include <os/lock.h>
|
||||
|
||||
void os_unfair_lock_lock(os_unfair_lock_t lock) {
|
||||
return OSSpinLockLock(lock);
|
||||
}
|
||||
|
||||
bool os_unfair_lock_trylock(os_unfair_lock_t lock) {
|
||||
return OSSpinLockTry(lock);
|
||||
}
|
||||
|
||||
void os_unfair_lock_unlock(os_unfair_lock_t lock) {
|
||||
return OSSpinLockUnlock(lock);
|
||||
}
|
||||
|
||||
#endif /*__MP_LEGACY_SUPPORT_OS_UNFAIR_LOCK__*/
|
54
extern/macports-legacy-support/src/macports_legacy_realpath.c
vendored
Normal file
54
extern/macports-legacy-support/src/macports_legacy_realpath.c
vendored
Normal file
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
* Copyright (c) 2019
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* MP support header */
|
||||
#include "MacportsLegacySupport.h"
|
||||
|
||||
/* realpath wrap */
|
||||
#if __MP_LEGACY_SUPPORT_REALPATH_WRAP__
|
||||
|
||||
#include <limits.h>
|
||||
#include <stdlib.h>
|
||||
#include <dlfcn.h>
|
||||
|
||||
char *realpath(const char * __restrict stringsearch, char * __restrict buffer)
|
||||
{
|
||||
char *(*real_realpath)(const char * __restrict, char * __restrict);
|
||||
#if (__DARWIN_UNIX03 && !defined(_POSIX_C_SOURCE)) || defined(_DARWIN_C_SOURCE) || defined(_DARWIN_BETTER_REALPATH)
|
||||
real_realpath = dlsym(RTLD_NEXT, "realpath$DARWIN_EXTSN");
|
||||
# else
|
||||
real_realpath = dlsym(RTLD_NEXT, "realpath");
|
||||
#endif
|
||||
if (real_realpath == NULL) {
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (buffer == NULL) {
|
||||
char *myrealpathbuf = malloc(PATH_MAX);
|
||||
if (myrealpathbuf != NULL) {
|
||||
return(real_realpath(stringsearch, myrealpathbuf));
|
||||
} else {
|
||||
return(NULL);
|
||||
}
|
||||
} else {
|
||||
return(real_realpath(stringsearch, buffer));
|
||||
}
|
||||
}
|
||||
|
||||
/* compatibility function so code does not have to be recompiled */
|
||||
char *macports_legacy_realpath(const char * __restrict stringsearch, char * __restrict buffer) { return realpath(stringsearch, buffer); }
|
||||
|
||||
#endif /*__MP_LEGACY_SUPPORT_REALPATH_WRAP__*/
|
63
extern/macports-legacy-support/src/macports_legacy_symbol_aliases.c
vendored
Normal file
63
extern/macports-legacy-support/src/macports_legacy_symbol_aliases.c
vendored
Normal file
|
@ -0,0 +1,63 @@
|
|||
/*
|
||||
* Copyright (c) 2024
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* MP support header */
|
||||
#include "MacportsLegacySupport.h"
|
||||
|
||||
#if __MP_LEGACY_SUPPORT_SYMBOL____bzero__
|
||||
#include <strings.h>
|
||||
/*
|
||||
The need for this function is highly limited.
|
||||
The symbol `__bzero` does not exist prior to 10.6.
|
||||
When the Rust stage0 compiler for 10.5 is built on newer machines, it bakes `__bzero` into librustc_driver-xxx.dylib.
|
||||
This may be due to the fact that on newer machines, the `_bzero` symbol is an indirect reference to another symbol.
|
||||
*/
|
||||
void __bzero(void *s, size_t n) { bzero(s, n); }
|
||||
#endif /* __MP_LEGACY_SUPPORT_SYMBOL_ALIASES__ */
|
||||
|
||||
#if __MP_LEGACY_SUPPORT_SYMBOL__dirfd__
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
#include <stddef.h>
|
||||
/*
|
||||
The need for this function is highly limited.
|
||||
Prior to 10.8, `dirfd` was a macro`.
|
||||
The Rust compiler requires `dirfd` to be a library symbol.
|
||||
*/
|
||||
#undef dirfd
|
||||
#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1050
|
||||
#define __dd_fd dd_fd
|
||||
#endif /* __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1050 */
|
||||
int dirfd(DIR *dirp)
|
||||
{
|
||||
if (dirp == NULL || dirp->__dd_fd < 0)
|
||||
{
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
return dirp->__dd_fd;
|
||||
}
|
||||
#endif /* __MP_LEGACY_SUPPORT_SYMBOL__dirfd__ */
|
||||
|
||||
#if __MP_LEGACY_SUPPORT_ATCALLS__ && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1050
|
||||
#include <sys/stat.h>
|
||||
/*
|
||||
The need for this function is highly limited.
|
||||
The Rust compiler requires `fstatat$INODE64` to be a library symbol.
|
||||
*/
|
||||
int fstatat$INODE64(int dirfd, const char *pathname, struct stat64 *buf, int flags) { return fstatat64(dirfd, pathname, buf, flags); }
|
||||
#endif /* __MP_LEGACY_SUPPORT_ATCALLS__ && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1050 */
|
98
extern/macports-legacy-support/src/macports_legacy_sysconf.c
vendored
Normal file
98
extern/macports-legacy-support/src/macports_legacy_sysconf.c
vendored
Normal file
|
@ -0,0 +1,98 @@
|
|||
/*
|
||||
* Copyright (c) 2019
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* MP support header */
|
||||
#include "MacportsLegacySupport.h"
|
||||
|
||||
/* sysconf wrap */
|
||||
#if __MP_LEGACY_SUPPORT_SYSCONF_WRAP__
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/sysctl.h>
|
||||
|
||||
#include <unistd.h>
|
||||
#include <dlfcn.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/* emulate several commonly used but missing selectors from sysconf() on various OS versions */
|
||||
|
||||
long sysconf(int name) {
|
||||
long (*real_sysconf)(int);
|
||||
|
||||
#if __MP_LEGACY_SUPPORT_SYSCONF_WRAP_NEED_SC_NPROCESSORS_ONLN__
|
||||
if ( name == _SC_NPROCESSORS_ONLN ) {
|
||||
|
||||
int nm[2];
|
||||
int ret;
|
||||
size_t len = 4;
|
||||
uint32_t count;
|
||||
|
||||
nm[0] = CTL_HW; nm[1] = HW_AVAILCPU;
|
||||
ret = sysctl(nm, 2, &count, &len, NULL, 0);
|
||||
|
||||
if (ret < 0 || count < 1) {
|
||||
/* try again with _SC_NPROCESSORS_CONF */
|
||||
return sysconf(_SC_NPROCESSORS_CONF);
|
||||
} else {
|
||||
return (long)count;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if __MP_LEGACY_SUPPORT_SYSCONF_WRAP_NEED_SC_NPROCESSORS_CONF__
|
||||
if ( name == _SC_NPROCESSORS_CONF ) {
|
||||
|
||||
int nm[2];
|
||||
int ret;
|
||||
size_t len = 4;
|
||||
uint32_t count;
|
||||
|
||||
nm[0] = CTL_HW; nm[1] = HW_NCPU;
|
||||
ret = sysctl(nm, 2, &count, &len, NULL, 0);
|
||||
|
||||
/* there has to be at least 1 processor */
|
||||
if (ret < 0 || count < 1) { count = 1; }
|
||||
return (long)count;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if __MP_LEGACY_SUPPORT_SYSCONF_WRAP_NEED_SC_PHYS_PAGES__
|
||||
if ( name == _SC_PHYS_PAGES ) {
|
||||
|
||||
/* the number of pages is the total memory / pagesize */
|
||||
uint64_t mem_size;
|
||||
size_t len = sizeof(mem_size);
|
||||
int pagesize = getpagesize();
|
||||
|
||||
sysctlbyname("hw.memsize", &mem_size, &len, NULL, 0);
|
||||
|
||||
return (long)(mem_size/pagesize);
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
/* for any other values of "name", call the real sysconf() */
|
||||
real_sysconf = dlsym(RTLD_NEXT, "sysconf");
|
||||
if (real_sysconf == NULL) {
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
return real_sysconf(name);
|
||||
}
|
||||
|
||||
/* compatibility function so code does not have to be recompiled */
|
||||
long macports_legacy_sysconf(int name) { return sysconf(name); }
|
||||
|
||||
#endif /*__MP_LEGACY_SUPPORT_SYSCONF_WRAP__*/
|
72
extern/macports-legacy-support/src/memmem.c
vendored
Normal file
72
extern/macports-legacy-support/src/memmem.c
vendored
Normal file
|
@ -0,0 +1,72 @@
|
|||
|
||||
/*-
|
||||
* Copyright (c) 2005 Pascal Gloor <pascal.gloor@spale.com>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote
|
||||
* products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/* MP support header */
|
||||
#include "MacportsLegacySupport.h"
|
||||
#if __MP_LEGACY_SUPPORT_MEMMEM__
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "strnlen.h"
|
||||
|
||||
/*
|
||||
* Find the first occurrence of the byte string s in byte string l.
|
||||
*/
|
||||
|
||||
void *
|
||||
memmem(const void *l, size_t l_len, const void *s, size_t s_len)
|
||||
{
|
||||
register char *cur, *last;
|
||||
const char *cl = (const char *)l;
|
||||
const char *cs = (const char *)s;
|
||||
|
||||
/* we need something to compare */
|
||||
if (l_len == 0 || s_len == 0)
|
||||
return NULL;
|
||||
|
||||
/* "s" must be smaller or equal to "l" */
|
||||
if (l_len < s_len)
|
||||
return NULL;
|
||||
|
||||
/* special case where s_len == 1 */
|
||||
if (s_len == 1)
|
||||
return memchr(l, (int)*cs, l_len);
|
||||
|
||||
/* the last position where its possible to find "s" in "l" */
|
||||
last = (char *)cl + l_len - s_len;
|
||||
|
||||
for (cur = (char *)cl; cur <= last; cur++)
|
||||
if (cur[0] == cs[0] && memcmp(cur, cs, s_len) == 0)
|
||||
return cur;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#endif /* __MP_LEGACY_SUPPORT_MEMMEM__ */
|
180
extern/macports-legacy-support/src/memstream.c
vendored
Normal file
180
extern/macports-legacy-support/src/memstream.c
vendored
Normal file
|
@ -0,0 +1,180 @@
|
|||
/* memstream.c
|
||||
*
|
||||
* This file is licensed under the MIT license by
|
||||
*
|
||||
* Copyright (c) 2013 Ian Piumarta.
|
||||
*
|
||||
* Modifications for inclusion in macports-legacy-support
|
||||
* Copyright (c) 2023 Dennis Camera.
|
||||
*
|
||||
* ----------------------------------------------------------------------------
|
||||
*
|
||||
* OPEN_MEMSTREAM(3) BSD and Linux Library Functions OPEN_MEMSTREAM(3)
|
||||
*
|
||||
* SYNOPSIS
|
||||
* FILE *open_memstream(char **bufp, size_t *sizep);
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The open_memstream() function opens a stream for writing to a buffer.
|
||||
* The buffer is dynamically allocated (as with malloc(3)), and
|
||||
* automatically grows as required. After closing the stream, the caller
|
||||
* should free(3) this buffer.
|
||||
*
|
||||
* When the stream is closed (fclose(3)) or flushed (fflush(3)), the
|
||||
* locations pointed to by bufp and sizep are updated to contain,
|
||||
* respectively, a pointer to the buffer and the current size of the
|
||||
* buffer. These values remain valid only as long as the caller performs
|
||||
* no further output on the stream. If further output is performed, then
|
||||
* the stream must again be flushed before trying to access these
|
||||
* variables.
|
||||
*
|
||||
* A null byte is maintained at the end of the buffer. This byte is not
|
||||
* included in the size value stored at sizep.
|
||||
*
|
||||
* The stream's file position can be changed with fseek(3) or fseeko(3).
|
||||
* Moving the file position past the end of the data already written fills
|
||||
* the intervening space with zeros.
|
||||
*
|
||||
* RETURN VALUE
|
||||
* Upon successful completion open_memstream() returns a FILE pointer.
|
||||
* Otherwise, NULL is returned and errno is set to indicate the error.
|
||||
*
|
||||
* CONFORMING TO
|
||||
* POSIX.1-2008
|
||||
*
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* MP support header */
|
||||
#include "MacportsLegacySupport.h"
|
||||
#if __MP_LEGACY_SUPPORT_OPEN_MEMSTREAM__
|
||||
|
||||
#include "stdio.h"
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <assert.h>
|
||||
|
||||
#define min(X, Y) (((X) < (Y)) ? (X) : (Y))
|
||||
|
||||
struct memstream
|
||||
{
|
||||
int position;
|
||||
int size;
|
||||
int capacity;
|
||||
char *contents;
|
||||
char **ptr;
|
||||
size_t *sizeloc;
|
||||
};
|
||||
|
||||
#if MEMSTREAM_DEBUG
|
||||
static void memstream_print(struct memstream *ms)
|
||||
{
|
||||
printf("memstream %p {", ms);
|
||||
printf(" %i", ms->position);
|
||||
printf(" %i", ms->size);
|
||||
printf(" %i", ms->capacity);
|
||||
printf(" %p", ms->contents);
|
||||
printf(" }\n");
|
||||
}
|
||||
# define memstream_info(ARGS) printf ARGS
|
||||
#else
|
||||
# define memstream_print(ms)
|
||||
# define memstream_info(ARGS)
|
||||
#endif
|
||||
|
||||
#define memstream_check(MS) if (!(MS)->contents) { errno= ENOMEM; return -1; }
|
||||
|
||||
static int memstream_grow(struct memstream *ms, int minsize)
|
||||
{
|
||||
int newcap= ms->capacity * 2; memstream_check(ms);
|
||||
while (newcap <= minsize) newcap *= 2; memstream_info(("grow %p to %i\n", ms, newcap));
|
||||
ms->contents= realloc(ms->contents, newcap);
|
||||
if (!ms->contents) return -1; /* errno == ENOMEM */
|
||||
memset(ms->contents + ms->capacity, 0, newcap - ms->capacity);
|
||||
ms->capacity= newcap;
|
||||
*ms->ptr= ms->contents; /* size has not changed */
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int memstream_read(void *cookie, char *buf, int count)
|
||||
{
|
||||
struct memstream *ms= (struct memstream *)cookie; memstream_check(ms);
|
||||
int n= min(ms->size - ms->position, count); memstream_info(("memstream_read %p %i\n", ms, count));
|
||||
if (n < 1) return 0;
|
||||
memcpy(buf, ms->contents, n);
|
||||
ms->position += n; memstream_print(ms);
|
||||
return n;
|
||||
}
|
||||
|
||||
static int memstream_write(void *cookie, const char *buf, int count)
|
||||
{
|
||||
struct memstream *ms= (struct memstream *)cookie; memstream_check(ms);
|
||||
if (ms->capacity <= ms->position + count)
|
||||
if (memstream_grow(ms, ms->position + count) < 0) /* errno == ENOMEM */
|
||||
return -1;
|
||||
memcpy(ms->contents + ms->position, buf, count); memstream_info(("memstream_write %p %i\n", ms, count));
|
||||
ms->position += count;
|
||||
if (ms->size < ms->position) *ms->sizeloc= ms->size= ms->position; memstream_print(ms);
|
||||
assert(ms->size < ms->capacity);
|
||||
assert(ms->contents[ms->size] == 0);
|
||||
return count;
|
||||
}
|
||||
|
||||
static fpos_t memstream_seek(void *cookie, fpos_t offset, int whence)
|
||||
{
|
||||
struct memstream *ms= (struct memstream *)cookie;
|
||||
fpos_t pos= 0; memstream_check(ms);
|
||||
memstream_info(("memstream_seek %p %i %i\n", ms, (int)offset, whence));
|
||||
switch (whence) {
|
||||
case SEEK_SET: pos= offset; break;
|
||||
case SEEK_CUR: pos= ms->position + offset; break;
|
||||
case SEEK_END: pos= ms->size + offset; break;
|
||||
default: errno= EINVAL; return -1;
|
||||
}
|
||||
if (pos >= ms->capacity) memstream_grow(ms, pos);
|
||||
ms->position= pos;
|
||||
if (ms->size < ms->position) *ms->sizeloc= ms->size= ms->position; memstream_print(ms); memstream_info(("=> %i\n", (int)pos));
|
||||
assert(ms->size < ms->capacity && ms->contents[ms->size] == 0);
|
||||
return pos;
|
||||
}
|
||||
|
||||
static int memstream_close(void *cookie)
|
||||
{
|
||||
struct memstream *ms= (struct memstream *)cookie; if (!ms->contents) { free(ms); errno= ENOMEM; return -1; }
|
||||
ms->size= min(ms->size, ms->position);
|
||||
*ms->ptr= ms->contents;
|
||||
*ms->sizeloc= ms->size; assert(ms->size < ms->capacity);
|
||||
ms->contents[ms->size]= 0;
|
||||
free(ms);
|
||||
return 0;
|
||||
}
|
||||
|
||||
FILE *open_memstream(char **ptr, size_t *sizeloc)
|
||||
{
|
||||
if (ptr && sizeloc) {
|
||||
struct memstream *ms= calloc(1, sizeof(struct memstream));
|
||||
FILE *fp= 0; if (!ms) return 0; /* errno == ENOMEM */
|
||||
ms->position= ms->size= 0;
|
||||
ms->capacity= 4096;
|
||||
ms->contents= calloc(ms->capacity, 1); if (!ms->contents) { free(ms); return 0; } /* errno == ENOMEM */
|
||||
ms->ptr= ptr;
|
||||
ms->sizeloc= sizeloc;
|
||||
memstream_print(ms);
|
||||
fp= funopen(ms, memstream_read, memstream_write, memstream_seek, memstream_close);
|
||||
if (!fp) {
|
||||
free(ms->contents);
|
||||
free(ms);
|
||||
return 0; /* errno set by funopen */
|
||||
}
|
||||
*ptr= ms->contents;
|
||||
*sizeloc= ms->size;
|
||||
return fp;
|
||||
}
|
||||
errno= EINVAL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* __MP_LEGACY_SUPPORT_OPEN_MEMSTREAM__ */
|
25
extern/macports-legacy-support/src/pthread_setname_np.c
vendored
Normal file
25
extern/macports-legacy-support/src/pthread_setname_np.c
vendored
Normal file
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
Until such time as this behavior can be emulated, do nothing and return success.
|
||||
* This is what the MacPorts SpiderMonkey does:
|
||||
https://github.com/macports/macports-ports/commit/50cdf084768436a421e2c6d05e995d122bc93bca
|
||||
* This is what the MacPorts LLVM does:
|
||||
https://github.com/macports/macports-ports/blob/master/lang/llvm-14/files/0007-Threading-Only-call-pthread_setname_np-if-we-have-it.patch
|
||||
* This is what upstream dav1d does:
|
||||
https://code.videolan.org/videolan/dav1d/-/blob/87f9a81cd770e49394a45deca7a3df41243de00b/src/thread.h#L182
|
||||
vs
|
||||
https://code.videolan.org/videolan/dav1d/-/blob/87f9a81cd770e49394a45deca7a3df41243de00b/src/thread.h#L182
|
||||
* This is what upstream Rust does:
|
||||
https://github.com/rust-lang/rust/blob/100f12d17026fccfc5d80527b5976dd66b228b13/library/std/src/sys/unix/thread.rs#L137
|
||||
vs
|
||||
https://github.com/rust-lang/rust/blob/100f12d17026fccfc5d80527b5976dd66b228b13/library/std/src/sys/unix/thread.rs#L199
|
||||
*/
|
||||
|
||||
/* MP support header */
|
||||
#include "MacportsLegacySupport.h"
|
||||
#if __MP_LEGACY_SUPPORT_PTHREAD_SETNAME_NP__
|
||||
|
||||
int pthread_setname_np(const char *name) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* __MP_LEGACY_SUPPORT_PTHREAD_SETNAME_NP__ */
|
36
extern/macports-legacy-support/src/sincos.c
vendored
Normal file
36
extern/macports-legacy-support/src/sincos.c
vendored
Normal file
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* Copyright (c) 2018 Chris Jones <jonesc@macports.org>
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* MP support header */
|
||||
#include <math.h>
|
||||
|
||||
#if __MP_LEGACY_SUPPORT_COSSIN__
|
||||
|
||||
/* Following is borrowed from math.h on macOS 10.9+ */
|
||||
|
||||
/* __sincos and __sincosf were introduced in OSX 10.9 and iOS 7.0. When
|
||||
targeting an older system, we simply split them up into discrete calls
|
||||
to sin( ) and cos( ). */
|
||||
void __sincosf(float __x, float *__sinp, float *__cosp) {
|
||||
*__sinp = sinf(__x);
|
||||
*__cosp = cosf(__x);
|
||||
}
|
||||
void __sincos(double __x, double *__sinp, double *__cosp) {
|
||||
*__sinp = sin(__x);
|
||||
*__cosp = cos(__x);
|
||||
}
|
||||
|
||||
#endif /* __MP_LEGACY_SUPPORT_COSSIN__ */
|
99
extern/macports-legacy-support/src/strings.c
vendored
Normal file
99
extern/macports-legacy-support/src/strings.c
vendored
Normal file
|
@ -0,0 +1,99 @@
|
|||
|
||||
/*-
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
* Copyright (c) 1990, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
// MP support header
|
||||
#include "MacportsLegacySupport.h"
|
||||
|
||||
#if __MP_LEGACY_SUPPORT_FFSL__
|
||||
int ffsl(long mask)
|
||||
{
|
||||
int bit = 0;
|
||||
if (mask != 0) {
|
||||
for (bit = 1; !(mask & 1); bit++) {
|
||||
mask = (unsigned long)mask >> 1;
|
||||
}
|
||||
}
|
||||
return (bit);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if __MP_LEGACY_SUPPORT_FFSLL__
|
||||
int ffsll(long long mask)
|
||||
{
|
||||
int bit = 0;
|
||||
if (mask != 0) {
|
||||
for (bit = 1; !(mask & 1); bit++) {
|
||||
mask = (unsigned long long)mask >> 1;
|
||||
}
|
||||
}
|
||||
return (bit);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if __MP_LEGACY_SUPPORT_FLS__
|
||||
int fls(int mask)
|
||||
{
|
||||
int bit = 0;
|
||||
if (mask != 0) {
|
||||
for (bit = 1; mask != 1; bit++) {
|
||||
mask = (unsigned int)mask >> 1;
|
||||
}
|
||||
}
|
||||
return (bit);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if __MP_LEGACY_SUPPORT_FLSL__
|
||||
int flsl(long mask)
|
||||
{
|
||||
int bit = 0;
|
||||
if (mask != 0) {
|
||||
for (bit = 1; mask != 1; bit++) {
|
||||
mask = (unsigned long)mask >> 1;
|
||||
}
|
||||
}
|
||||
return (bit);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if __MP_LEGACY_SUPPORT_FLSLL__
|
||||
int flsll(long long mask)
|
||||
{
|
||||
int bit = 0;
|
||||
if (mask != 0) {
|
||||
for (bit = 1; mask != 1; bit++) {
|
||||
mask = (unsigned long long)mask >> 1;
|
||||
}
|
||||
}
|
||||
return (bit);
|
||||
}
|
||||
#endif
|
66
extern/macports-legacy-support/src/strndup.c
vendored
Normal file
66
extern/macports-legacy-support/src/strndup.c
vendored
Normal file
|
@ -0,0 +1,66 @@
|
|||
|
||||
/*
|
||||
* Copyright (c) 1995 - 1999 Kungliga Tekniska Högskolan
|
||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
// MP support header
|
||||
#include "MacportsLegacySupport.h"
|
||||
#if __MP_LEGACY_SUPPORT_STRNDUP__
|
||||
|
||||
#ifndef HAVE_STRNDUP
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "strnlen.h"
|
||||
|
||||
char *
|
||||
strndup (const char *old, size_t sz)
|
||||
{
|
||||
size_t len = strnlen (old, sz);
|
||||
char *t = malloc(len + 1);
|
||||
|
||||
if (t != NULL) {
|
||||
memcpy (t, old, len);
|
||||
t[len] = '\0';
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
#endif /* HAVE_STRNDUP */
|
||||
|
||||
#endif /* __MP_LEGACY_SUPPORT_STRDUP__ */
|
41
extern/macports-legacy-support/src/strndup.h
vendored
Normal file
41
extern/macports-legacy-support/src/strndup.h
vendored
Normal file
|
@ -0,0 +1,41 @@
|
|||
|
||||
/*
|
||||
* Copyright (c) 1995 - 1999 Kungliga Tekniska Högskolan
|
||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef HAVE_STRNDUP
|
||||
#define HAVE_STRNDUP
|
||||
|
||||
char *strndup(const char *s, size_t n);
|
||||
|
||||
#endif /* HAVE_STRNDUP */
|
58
extern/macports-legacy-support/src/strnlen.c
vendored
Normal file
58
extern/macports-legacy-support/src/strnlen.c
vendored
Normal file
|
@ -0,0 +1,58 @@
|
|||
|
||||
/*
|
||||
* Copyright (c) 1995 - 1999 Kungliga Tekniska Högskolan
|
||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
// MP support header
|
||||
#include "MacportsLegacySupport.h"
|
||||
#if __MP_LEGACY_SUPPORT_STRNLEN__
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include "strnlen.h"
|
||||
|
||||
/* Find the length of STRING, but scan at most MAXLEN characters.
|
||||
If no '\0' terminator is found in that many characters, return MAXLEN. */
|
||||
|
||||
size_t
|
||||
strnlen (const char *s, size_t len)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
for(i = 0; i < len && s[i]; i++)
|
||||
;
|
||||
return i;
|
||||
}
|
||||
|
||||
#endif
|
46
extern/macports-legacy-support/src/strnlen.h
vendored
Normal file
46
extern/macports-legacy-support/src/strnlen.h
vendored
Normal file
|
@ -0,0 +1,46 @@
|
|||
|
||||
/*
|
||||
* Copyright (c) 1995 - 1999 Kungliga Tekniska Högskolan
|
||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef STRNLEN_H
|
||||
#define STRNLEN_H
|
||||
|
||||
/* Get strnlen declaration, if available. */
|
||||
#include <string.h>
|
||||
|
||||
/* Find the length (number of bytes) of STRING, but scan at most
|
||||
MAXLEN bytes. If no '\0' terminator is found in that many bytes,
|
||||
return MAXLEN. */
|
||||
extern size_t strnlen(const char *s, size_t len);
|
||||
|
||||
#endif /* STRNLEN_H */
|
147
extern/macports-legacy-support/src/time.c
vendored
Normal file
147
extern/macports-legacy-support/src/time.c
vendored
Normal file
|
@ -0,0 +1,147 @@
|
|||
|
||||
/*
|
||||
* Copyright (c) 2018 Chris Jones <jonesc@macports.org>
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "time.h"
|
||||
|
||||
#if __MP_LEGACY_SUPPORT_GETTIME__
|
||||
|
||||
#include <sys/time.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/resource.h>
|
||||
|
||||
#include <mach/mach_init.h>
|
||||
#include <mach/mach_port.h>
|
||||
#include <mach/mach_time.h>
|
||||
#include <mach/thread_act.h>
|
||||
|
||||
#define BILLION 1000000000L
|
||||
#define MILLION 1000000L
|
||||
#define THOUSAND 1000L
|
||||
|
||||
int clock_gettime( clockid_t clk_id, struct timespec *ts )
|
||||
{
|
||||
int ret = -1;
|
||||
if ( ts )
|
||||
{
|
||||
if ( CLOCK_REALTIME == clk_id )
|
||||
{
|
||||
struct timeval tv;
|
||||
ret = gettimeofday(&tv, NULL);
|
||||
ts->tv_sec = tv.tv_sec;
|
||||
ts->tv_nsec = tv.tv_usec * 1000;
|
||||
}
|
||||
else if ( CLOCK_MONOTONIC == clk_id )
|
||||
{
|
||||
struct timeval boottime;
|
||||
size_t boottime_len = sizeof(boottime);
|
||||
ret = sysctlbyname("kern.boottime", &boottime, &boottime_len, NULL, 0);
|
||||
if (ret != KERN_SUCCESS) { return ret; }
|
||||
struct timeval tv;
|
||||
ret = gettimeofday(&tv, NULL);
|
||||
timersub(&tv, &boottime, &tv);
|
||||
ts->tv_sec = tv.tv_sec;
|
||||
ts->tv_nsec = tv.tv_usec * 1000;
|
||||
ret = 0;
|
||||
}
|
||||
else if ( CLOCK_PROCESS_CPUTIME_ID == clk_id )
|
||||
{
|
||||
struct rusage ru;
|
||||
ret = getrusage(RUSAGE_SELF, &ru);
|
||||
timeradd(&ru.ru_utime, &ru.ru_stime, &ru.ru_utime);
|
||||
ts->tv_sec = ru.ru_utime.tv_sec;
|
||||
ts->tv_nsec = ru.ru_utime.tv_usec * 1000;
|
||||
}
|
||||
else if ( CLOCK_THREAD_CPUTIME_ID == clk_id )
|
||||
{
|
||||
mach_msg_type_number_t count = THREAD_BASIC_INFO_COUNT;
|
||||
thread_basic_info_data_t info;
|
||||
|
||||
thread_port_t thread = mach_thread_self();
|
||||
ret = thread_info(thread, THREAD_BASIC_INFO, (thread_info_t) &info, &count);
|
||||
mach_port_deallocate(mach_task_self(), thread);
|
||||
|
||||
time_value_add(&info.user_time, &info.system_time);
|
||||
ts->tv_sec = info.user_time.seconds;
|
||||
ts->tv_nsec = info.user_time.microseconds * 1000;
|
||||
}
|
||||
else if ( CLOCK_MONOTONIC_RAW == clk_id ||
|
||||
CLOCK_MONOTONIC_RAW_APPROX == clk_id ||
|
||||
CLOCK_UPTIME_RAW == clk_id ||
|
||||
CLOCK_UPTIME_RAW_APPROX == clk_id )
|
||||
{
|
||||
static mach_timebase_info_data_t timebase;
|
||||
if ( 0 == timebase.numer || 0 == timebase.denom ) {
|
||||
const kern_return_t kr = mach_timebase_info( &timebase );
|
||||
if ( kr != KERN_SUCCESS ) { return kr; }
|
||||
}
|
||||
uint64_t tdiff = mach_absolute_time() * ( timebase.numer / timebase.denom );
|
||||
ts->tv_sec = tdiff / BILLION;
|
||||
ts->tv_nsec = tdiff % BILLION;
|
||||
ret = 0;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int clock_getres( clockid_t clk_id, struct timespec *ts )
|
||||
{
|
||||
int ret = -1;
|
||||
if ( ts )
|
||||
{
|
||||
if ( CLOCK_REALTIME == clk_id ||
|
||||
CLOCK_MONOTONIC == clk_id ||
|
||||
CLOCK_PROCESS_CPUTIME_ID == clk_id ||
|
||||
CLOCK_THREAD_CPUTIME_ID == clk_id)
|
||||
{
|
||||
// return 1us precision
|
||||
ts->tv_sec = 0;
|
||||
ts->tv_nsec = THOUSAND;
|
||||
ret = 0;
|
||||
}
|
||||
else if ( CLOCK_MONOTONIC_RAW == clk_id ||
|
||||
CLOCK_MONOTONIC_RAW_APPROX == clk_id ||
|
||||
CLOCK_UPTIME_RAW == clk_id ||
|
||||
CLOCK_UPTIME_RAW_APPROX == clk_id )
|
||||
{
|
||||
// return 1ns precision
|
||||
ts->tv_sec = 0;
|
||||
ts->tv_nsec = 1;
|
||||
ret = 0;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if __MP_LEGACY_SUPPORT_TIMESPEC_GET__
|
||||
|
||||
int timespec_get(struct timespec *ts, int base)
|
||||
{
|
||||
switch (base) {
|
||||
case TIME_UTC:
|
||||
if (clock_gettime(CLOCK_REALTIME, ts) == -1) {
|
||||
return 0;
|
||||
}
|
||||
return base;
|
||||
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
37
extern/macports-legacy-support/src/wcpcpy_family.c
vendored
Normal file
37
extern/macports-legacy-support/src/wcpcpy_family.c
vendored
Normal file
|
@ -0,0 +1,37 @@
|
|||
|
||||
/*
|
||||
* Copyright (c) 2018 Christian Cornelssen
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
// MP support header
|
||||
#include "MacportsLegacySupport.h"
|
||||
#if __MP_LEGACY_SUPPORT_WCPCPY__
|
||||
|
||||
#include <wchar.h>
|
||||
|
||||
wchar_t *wcpncpy(wchar_t *__restrict d, const wchar_t *__restrict s, size_t n)
|
||||
{
|
||||
wint_t c;
|
||||
while (n && (c = *s)) --n, *d++ = c, ++s;
|
||||
return wmemset(d, 0, n);
|
||||
}
|
||||
|
||||
wchar_t *wcpcpy(wchar_t *__restrict d, const wchar_t *__restrict s)
|
||||
{
|
||||
while ((*d = *s)) ++d, ++s;
|
||||
return d;
|
||||
}
|
||||
|
||||
#endif /* __MP_LEGACY_SUPPORT_WCPCPY__ */
|
65
extern/macports-legacy-support/src/wcscasecmp_family.c
vendored
Normal file
65
extern/macports-legacy-support/src/wcscasecmp_family.c
vendored
Normal file
|
@ -0,0 +1,65 @@
|
|||
|
||||
/*
|
||||
* Copyright (c) 2018 Christian Cornelssen
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
// MP support header
|
||||
#include "MacportsLegacySupport.h"
|
||||
#if __MP_LEGACY_SUPPORT_WCSCASECMP__
|
||||
|
||||
#include <wchar.h>
|
||||
#include <wctype.h>
|
||||
#include <xlocale.h>
|
||||
|
||||
#include <limits.h>
|
||||
#include <stdint.h>
|
||||
#if WCHAR_MAX > INT_MAX
|
||||
/* Caution: multiple argument evaluations */
|
||||
#define _MP_WCDIFFSIGN(a, b) (((b) < (a)) - ((a) < (b)))
|
||||
#else
|
||||
#define _MP_WCDIFFSIGN(a, b) ((int)(a) - (int)(b))
|
||||
#endif
|
||||
|
||||
int wcsncasecmp_l(const wchar_t *l, const wchar_t *r, size_t n, locale_t locale)
|
||||
{
|
||||
wint_t lc, rc;
|
||||
int d = 0;
|
||||
while (!d && n) {
|
||||
lc = *l++; rc = *r++; --n;
|
||||
if (!(lc && rc)) n = 0;
|
||||
if (lc == rc) continue;
|
||||
lc = towlower_l(lc, locale);
|
||||
rc = towlower_l(rc, locale);
|
||||
d = _MP_WCDIFFSIGN(lc, rc);
|
||||
}
|
||||
return d;
|
||||
}
|
||||
|
||||
int wcsncasecmp(const wchar_t *l, const wchar_t *r, size_t n)
|
||||
{
|
||||
return wcsncasecmp_l(l, r, n, 0);
|
||||
}
|
||||
|
||||
int wcscasecmp_l(const wchar_t *l, const wchar_t *r, locale_t locale)
|
||||
{
|
||||
return wcsncasecmp_l(l, r, -1, locale);
|
||||
}
|
||||
|
||||
int wcscasecmp(const wchar_t *l, const wchar_t *r)
|
||||
{
|
||||
return wcsncasecmp_l(l, r, -1, 0);
|
||||
}
|
||||
|
||||
#endif /* __MP_LEGACY_SUPPORT_WCSCASECMP__ */
|
49
extern/macports-legacy-support/src/wcsdup.c
vendored
Normal file
49
extern/macports-legacy-support/src/wcsdup.c
vendored
Normal file
|
@ -0,0 +1,49 @@
|
|||
|
||||
/*-
|
||||
* Copyright (c) 2005 Tim J. Robbins.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
// MP support header
|
||||
#include "MacportsLegacySupport.h"
|
||||
#if __MP_LEGACY_SUPPORT_WCSDUP__
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#include <stdlib.h>
|
||||
#include <wchar.h>
|
||||
|
||||
wchar_t *
|
||||
wcsdup(const wchar_t *s)
|
||||
{
|
||||
wchar_t *copy;
|
||||
size_t len;
|
||||
|
||||
len = wcslen(s) + 1;
|
||||
if ((copy = malloc(len * sizeof(wchar_t))) == NULL)
|
||||
return (NULL);
|
||||
return (wmemcpy(copy, s, len));
|
||||
}
|
||||
|
||||
#endif /* __MP_LEGACY_SUPPORT_WCSDUP__ */
|
||||
|
44
extern/macports-legacy-support/src/wcsnlen.c
vendored
Normal file
44
extern/macports-legacy-support/src/wcsnlen.c
vendored
Normal file
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* Adapted for MacportsLegacySupport from:
|
||||
* https://git.musl-libc.org/cgit/musl/tree/src/string/wcsnlen.c
|
||||
* License text (excerpt below):
|
||||
* https://git.musl-libc.org/cgit/musl/tree/COPYRIGHT
|
||||
*
|
||||
* musl as a whole is licensed under the following standard MIT license:
|
||||
*
|
||||
* Copyright © 2005-2014 Rich Felker, et al.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
// MP support header
|
||||
#include "MacportsLegacySupport.h"
|
||||
#if __MP_LEGACY_SUPPORT_WCSNLEN__
|
||||
|
||||
#include <wchar.h>
|
||||
|
||||
size_t wcsnlen(const wchar_t *s, size_t n)
|
||||
{
|
||||
const wchar_t *z = wmemchr(s, 0, n);
|
||||
if (z) n = z-s;
|
||||
return n;
|
||||
}
|
||||
|
||||
#endif /* __MP_LEGACY_SUPPORT_WCSNLEN__ */
|
Loading…
Reference in a new issue