├── xcodescripts ├── strip-header.ed ├── skip_installhdrs.sh ├── sim-compat-symlink.sh ├── force_libc_to_build.sh ├── abort_unsupported.sh ├── alias.list ├── legacy_alias.list ├── sanitise_headers.sh ├── libc_static.xcconfig ├── build_linklists.sh └── eos.xcconfig ├── fbsdcompat ├── port_after.h ├── port_before.h ├── namespace.h ├── machine │ └── atomic.h ├── un-namespace.h └── sys │ └── endian.h ├── tests ├── regex │ └── datafiles │ │ ├── union-enhanced.dat │ │ ├── misc-enhanced.dat │ │ ├── 11991275.dat │ │ ├── characterclass.dat │ │ ├── 6440240.dat │ │ ├── 2692334.dat │ │ ├── OpenBSD-enhanced.dat │ │ ├── rightbracket.dat │ │ ├── 5549951.dat │ │ ├── 3734286.dat │ │ ├── 6481680.dat │ │ ├── 6487297.dat │ │ ├── 3936073.dat │ │ ├── rightparen.dat │ │ ├── 3835390.dat │ │ ├── 6487583.dat │ │ ├── tre-bugs.dat │ │ ├── empty.dat │ │ ├── need-parenthesis-enhanced.dat │ │ ├── union.dat │ │ ├── iteration.dat │ │ ├── ISO8859-1.dat │ │ ├── eucJP.dat │ │ ├── 5518392.dat │ │ ├── need-parenthesis.dat │ │ ├── UTF-8.dat │ │ ├── tre-enhanced.dat │ │ ├── conformance-vsc-ed.dat │ │ ├── implementation_choices.dat │ │ ├── rightassoc.dat │ │ ├── misc.dat │ │ ├── 14189743.dat │ │ └── forcedassoc.dat ├── acl_tests.c ├── strlcpy.c ├── timespec_get.c ├── assumes_legacy.c ├── flockfile.c ├── err.c ├── readpassphrase.c ├── wchar.c ├── locale.c ├── assumes.c ├── nxheap.c ├── open_memstream.c ├── timingsafe_bcmp.c ├── os_simple_hash.c ├── printf.c └── qsort.c ├── gdtoa ├── gdtoa.tgz ├── FreeBSD │ ├── glue.c │ └── gdtoa_fltrnds.h └── gd_qnan.h ├── uuid ├── uuidman.sed ├── namespace.h └── uuid-config.h ├── regex └── TRE │ ├── tre-0.8.0.tar.bz2 │ ├── lib │ ├── tre-match-parallel.c │ └── tre-compile.h │ └── tre-config.h ├── string ├── FreeBSD │ ├── strrchr.c │ ├── timingsafe_bcmp.c │ ├── wcschr.c │ └── wcsnlen.c ├── bcopy.c ├── memset_pattern.3 ├── stpcpy.c └── strcat.c ├── .gitignore ├── stdlib ├── FreeBSD │ ├── qsort_r.c │ ├── _Exit_.c │ ├── remque.c │ ├── insque.c │ ├── tfind.c │ ├── insque.3 │ ├── llabs.c │ ├── imaxabs.c │ ├── tsearch.c │ └── twalk.c ├── qsort_b.c ├── a64l.c └── l64a.c ├── libdarwin ├── AppleInternalVariant.plist ├── AppleFactoryVariant.plist ├── init.c └── h │ ├── libdarwin_init.h │ └── dirstat_collection.h ├── darwin ├── forceLibcToBuild.c └── atexit_receipt.c ├── locale ├── FreeBSD │ ├── rune32.h │ └── nomacros.c ├── freelocale.3 ├── uselocale.3 ├── duplocale.3 ├── querylocale.3 ├── isctype.c ├── iswctype.c └── runedepreciated.h ├── gen ├── FreeBSD │ ├── getprogname.c │ ├── srand48.c │ ├── _rand48.c │ ├── lrand48.c │ ├── drand48.c │ ├── mrand48.c │ ├── nrand48.c │ ├── erand48.c │ ├── jrand48.c │ ├── lcong48.c │ ├── setprogname.c │ ├── seed48.c │ └── scandir_b.c ├── __dirent.h ├── dirfd.c ├── get_compat.h ├── raise.c ├── thread_stack_pcs.h └── utmpx_thread.h ├── include ├── fcntl.h ├── errno.h ├── syslog.h ├── poll.h ├── _ctermid.h ├── semaphore.h ├── termios.h ├── aio.h ├── xlocale │ ├── _langinfo.h │ ├── _monetary.h │ └── _string.h ├── standards.h ├── _xlocale.h ├── authentication.h ├── _types │ ├── _uint8_t.h │ ├── _uint32_t.h │ ├── _uint16_t.h │ ├── _uint64_t.h │ ├── _nl_item.h │ ├── _wctype_t.h │ ├── _wctrans_t.h │ ├── _intmax_t.h │ └── _uintmax_t.h ├── secure │ └── _common.h ├── alloca.h ├── search.h ├── crt_externs.h ├── ulimit.h └── readpassphrase.h ├── nbsdcompat ├── namespace.h └── _nbsd_compat_.h ├── emulated ├── lchflags.3 ├── lchmod.3 ├── tcgetsid.c ├── bsd_signal.c ├── lchmod.c ├── lchflags.c └── lutimes.3 ├── Platforms ├── appletvos │ └── Makefile.inc ├── bridgeos │ └── Makefile.inc ├── iphoneos │ └── Makefile.inc ├── watchos │ └── Makefile.inc ├── driverkit │ └── Makefile.inc └── macosx │ └── Makefile.inc ├── stdtime └── timezone_unix03.c ├── sys ├── OSMemoryNotification.c └── umaskx_np.c ├── man └── gethostuuid.2 ├── secure ├── memset_chk.c ├── memmove_chk.c ├── vsnprintf_chk.c ├── strlcpy_chk.c ├── strcpy_chk.c ├── stpcpy_chk.c ├── secure.h ├── memcpy_chk.c ├── strcat_chk.c ├── vsprintf_chk.c ├── memccpy_chk.c ├── strncpy_chk.c ├── stpncpy_chk.c └── strncat_chk.c ├── compat-43 └── sigaltstk.c ├── net └── FreeBSD │ └── sockatmark.c ├── i386 └── gen │ └── mcount.s └── stdio └── FreeBSD └── getline.c /xcodescripts/strip-header.ed: -------------------------------------------------------------------------------- 1 | g/^\/\/Begin-Libc$/.,/^\/\/End-Libc$/d 2 | w 3 | -------------------------------------------------------------------------------- /fbsdcompat/port_after.h: -------------------------------------------------------------------------------- 1 | /* FreeBSD only needs this for isc, nameser and resolv */ 2 | -------------------------------------------------------------------------------- /fbsdcompat/port_before.h: -------------------------------------------------------------------------------- 1 | /* FreeBSD only needs this for isc, nameser and resolv */ 2 | -------------------------------------------------------------------------------- /tests/regex/datafiles/union-enhanced.dat: -------------------------------------------------------------------------------- 1 | EH (?:(a)|(b)|c|d)* ab (0,2)(?,?)(1,2) 2 | -------------------------------------------------------------------------------- /tests/regex/datafiles/misc-enhanced.dat: -------------------------------------------------------------------------------- 1 | EH ^(?:(hello)|($)) hello asdf (0,5)(0,5)(?,?) 2 | -------------------------------------------------------------------------------- /gdtoa/gdtoa.tgz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apple-open-source-mirror/Libc/HEAD/gdtoa/gdtoa.tgz -------------------------------------------------------------------------------- /tests/regex/datafiles/11991275.dat: -------------------------------------------------------------------------------- 1 | E$ [^={} \t]+ ={}\nfred (3,8) 2 | En$ [^={} \t]+ ={}\nfred (4,8) 3 | -------------------------------------------------------------------------------- /tests/regex/datafiles/characterclass.dat: -------------------------------------------------------------------------------- 1 | B [[:digit:]]* 123abc (0,3) 2 | E [[:digit:]]* 123abc (0,3) 3 | -------------------------------------------------------------------------------- /uuid/uuidman.sed: -------------------------------------------------------------------------------- 1 | s/@E2FSPROGS_MONTH@/April/g 2 | s/@E2FSPROGS_YEAR@/2004/g 3 | s/@E2FSPROGS_VERSION@/1.36/g 4 | -------------------------------------------------------------------------------- /tests/regex/datafiles/6440240.dat: -------------------------------------------------------------------------------- 1 | {C en_US.UTF-8 2 | B$ .*\\(.\\{2\\}\\) \xe9\x9b\xaa\xe8\xb1\xb9 (0,6)(0,6) 3 | } 4 | -------------------------------------------------------------------------------- /regex/TRE/tre-0.8.0.tar.bz2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apple-open-source-mirror/Libc/HEAD/regex/TRE/tre-0.8.0.tar.bz2 -------------------------------------------------------------------------------- /tests/regex/datafiles/2692334.dat: -------------------------------------------------------------------------------- 1 | E .[.]*\.net$ x.net (0,5) 2 | E .+\.net$ x.net (0,5) 3 | E xnet x.net NOMATCH 4 | -------------------------------------------------------------------------------- /tests/regex/datafiles/OpenBSD-enhanced.dat: -------------------------------------------------------------------------------- 1 | BEH a\bc abc NOMATCH 2 | BEH \bab abc (0,2) 3 | EH a{1}? abc (0,1) 4 | -------------------------------------------------------------------------------- /tests/regex/datafiles/rightbracket.dat: -------------------------------------------------------------------------------- 1 | E ] [abc][def] (4,5) 2 | E []-] [abc][def] (4,5) 3 | E []-] [a-c][def] (2,3) 4 | -------------------------------------------------------------------------------- /regex/TRE/lib/tre-match-parallel.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apple-open-source-mirror/Libc/HEAD/regex/TRE/lib/tre-match-parallel.c -------------------------------------------------------------------------------- /tests/regex/datafiles/5549951.dat: -------------------------------------------------------------------------------- 1 | {C en_US.UTF-8 2 | B$ .*GUI \\([0-9.]\\{3,\\}\\).* GUI 1.21 (4835), \xc2\xa9 Foo (0,23)(4,8) 3 | } 4 | -------------------------------------------------------------------------------- /tests/regex/datafiles/3734286.dat: -------------------------------------------------------------------------------- 1 | BE [^---] - NOMATCH 2 | BE []-a] _ (0,1) 3 | BE [--\] A (0,1) 4 | BE [[=*=]][[=\=]][[=]=]][[===]][[...]][[:punct:]] *\]=., (0,6) 5 | -------------------------------------------------------------------------------- /tests/regex/datafiles/6481680.dat: -------------------------------------------------------------------------------- 1 | E (X)(aba|b|ab)(aba|b|ab)(Y)(aba|b|ab)*(Z) XababaYababaZ (0,13)(0,1)(1,3)(3,6)(6,7)(9,12)(12,13) 2 | E (aba|ab|a)* ababa (0,5)(2,5) 3 | -------------------------------------------------------------------------------- /tests/regex/datafiles/6487297.dat: -------------------------------------------------------------------------------- 1 | E (a)?(ab)?(b)? ab (0,2)(0,1)(?,?)(1,2) 2 | E (a)?((ab)?(b)?) ab (0,2)(0,1)(1,2)(?,?)(1,2) 3 | E ((a)?(ab)?)(b)? ab (0,2)(0,2)(?,?)(0,2)(?,?) 4 | -------------------------------------------------------------------------------- /tests/regex/datafiles/3936073.dat: -------------------------------------------------------------------------------- 1 | B \(a\)\1\{1,2\} abc NOMATCH 2 | B \(a\)\1\{1,2\} aabc (0,2)(0,1) 3 | B \(a\)\1\{1,2\} aaabc (0,3)(0,1) 4 | B \(a\)\1\{1,2\} aaaabc (0,3)(0,1) 5 | -------------------------------------------------------------------------------- /tests/regex/datafiles/rightparen.dat: -------------------------------------------------------------------------------- 1 | B \) x EPAREN 2 | B \(\)\) x EPAREN 3 | E ) x NOMATCH 4 | E ) ) (0,1) 5 | E ()) ) (0,1)(0,0) 6 | E (()|a)) a) (0,2)(0,1)(?,?) 7 | E \\) \) (0,2) 8 | -------------------------------------------------------------------------------- /tests/regex/datafiles/3835390.dat: -------------------------------------------------------------------------------- 1 | B \(ab*\)\{1,9\}\1 abbbabbabbbbb (0,10)(4,7) 2 | B \(ab\(xyz\)*\)\(c\(d\)*\)\{0,3\} abcdcdc (0,7)(0,2)(?,?)(6,7)(?,?) 3 | B \(^a\)\1 aabc (0,2)(0,1) 4 | -------------------------------------------------------------------------------- /tests/regex/datafiles/6487583.dat: -------------------------------------------------------------------------------- 1 | E (()|.)(b) ab (0,2)(0,1)(?,?)(1,2) 2 | E (()|.)(.) ab (0,2)(0,1)(?,?)(1,2) 3 | E (.|())(b) ab (0,2)(0,1)(?,?)(1,2) 4 | E (.|())(.) ab (0,2)(0,1)(?,?)(1,2) 5 | -------------------------------------------------------------------------------- /string/FreeBSD/strrchr.c: -------------------------------------------------------------------------------- 1 | #include 2 | __FBSDID("$FreeBSD: src/lib/libc/string/strrchr.c,v 1.2 2002/03/22 21:53:19 obrien Exp $"); 3 | 4 | #define STRRCHR 5 | #include "rindex.c" 6 | -------------------------------------------------------------------------------- /tests/regex/datafiles/tre-bugs.dat: -------------------------------------------------------------------------------- 1 | E (a|b|\|) | (0,1)(0,1) 2 | B \\(^ \(^ (0,3) 3 | B a*+ aa+ (0,3) 4 | B a\{2\}+ aa+ (0,3) 5 | EH \Q\t*\E \t* (0,3) 6 | EH \Q\\t*\E \\t* (0,4) 7 | -------------------------------------------------------------------------------- /tests/regex/datafiles/empty.dat: -------------------------------------------------------------------------------- 1 | E (a*)x x (0,1)(0,0) 2 | E (a)*x x (0,1)(?,?) 3 | E (a*)*x x (0,1)(0,0) 4 | E (a+)x x NOMATCH 5 | E (a)+x x NOMATCH 6 | E (a+)*x x (0,1)(?,?) 7 | E (a*)+x x (0,1)(0,0) 8 | -------------------------------------------------------------------------------- /tests/regex/datafiles/need-parenthesis-enhanced.dat: -------------------------------------------------------------------------------- 1 | EH (a+?b*)((?:a|b)+) aaab (0,4)(0,1)(1,4) 2 | EH ((a+?)(b*))((a|b)+) aaab (0,4)(0,1)(0,1)(1,1)(1,4)(3,4) 3 | EH ((a+?)b*)((?:a|b)+) aaab (0,4)(0,1)(0,1)(1,4) 4 | -------------------------------------------------------------------------------- /xcodescripts/skip_installhdrs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [[ "x${ACTION}" == "xinstallhdrs" ]]; then 4 | exit 0 5 | fi 6 | 7 | if [[ "x${ACTION}" == "xinstallapi" ]]; then 8 | exit 0 9 | fi 10 | 11 | $@ 12 | -------------------------------------------------------------------------------- /tests/regex/datafiles/union.dat: -------------------------------------------------------------------------------- 1 | E ((b*)|c(c*))* cbb (0,3)(1,3)(1,3)(?,?) 2 | E ((a)|x($))* ax (0,2)(1,2)(?,?)(2,2) 3 | E ((a)|b|c|x(dd|(e)(e)|ff))* abxee (0,5)(2,5)(?,?)(3,5)(3,4)(4,5) 4 | E a|b|c|ee|ff abee (0,1) 5 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | build/ 3 | .DS_Store 4 | *.xcodeproj/*.mode* 5 | *.xcodeproj/*.pbxuser 6 | *.xcodeproj/*.perspectivev3 7 | 8 | # /Libc.xcodeproj/ 9 | /Libc.xcodeproj/project.xcworkspace 10 | /Libc.xcodeproj/xcuserdata 11 | /Libc.xcodeproj/xcshareddata 12 | -------------------------------------------------------------------------------- /tests/acl_tests.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | T_DECL(acl_bad_test, "Tests invalid acl") { 6 | 7 | acl_t acl = acl_from_text("!#acl"); 8 | T_EXPECT_NULL(acl, "Invalid acl detected"); 9 | } 10 | -------------------------------------------------------------------------------- /stdlib/FreeBSD/qsort_r.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is in the public domain. Originally written by Garrett 3 | * A. Wollman. 4 | * 5 | * $FreeBSD: src/lib/libc/stdlib/qsort_r.c,v 1.1 2002/09/10 02:04:49 wollman Exp $ 6 | */ 7 | #define I_AM_QSORT_R 8 | #include "qsort.c" 9 | -------------------------------------------------------------------------------- /tests/regex/datafiles/iteration.dat: -------------------------------------------------------------------------------- 1 | :RE#36:E (a(b)?)+ aba (0,3)(2,3)(?,?) 2 | E (a(b?))+ aba (0,3)(2,3)(3,3) 3 | :RE#83:E (aa(b(b))?)+ aabbaa (0,6)(4,6)(?,?)(?,?) 4 | E zz|(aa(b(b))?)+ aabbaa (0,6)(4,6)(?,?)(?,?) 5 | E (zz|aa(b(b))?)+ aabbaa (0,6)(4,6)(?,?)(?,?) 6 | -------------------------------------------------------------------------------- /xcodescripts/sim-compat-symlink.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -ex 2 | 3 | if [[ "${ACTION}" == "installhdrs" ]]; then 4 | exit 0 5 | fi 6 | 7 | if [[ "${PLATFORM_NAME}" =~ "simulator" ]]; then 8 | ln -s libsystem_c.dylib ${DSTROOT}${INSTALL_PATH}/libsystem_sim_c.dylib 9 | fi 10 | -------------------------------------------------------------------------------- /gdtoa/FreeBSD/glue.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Machine-independent glue to integrate David Gay's gdtoa 3 | * package into libc. 4 | * 5 | * $FreeBSD: src/lib/libc/gdtoa/glue.c,v 1.1 2003/03/12 20:29:58 das Exp $ 6 | */ 7 | 8 | #include "spinlock.h" 9 | 10 | spinlock_t __gdtoa_locks[2]; 11 | -------------------------------------------------------------------------------- /libdarwin/AppleInternalVariant.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | AppleInternal 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /libdarwin/AppleFactoryVariant.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | AppleInternal-Factory 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /tests/regex/datafiles/ISO8859-1.dat: -------------------------------------------------------------------------------- 1 | {C en_US.ISO8859-1 2 | E$ [\xc0-\xd6] abc NOMATCH 3 | E$ [\xc0-\xd6] \xe1 NOMATCH 4 | Ei$ [\xc0-\xd6] \xe1 (0,1) 5 | E$ [[:lower:]] \xe1 (0,1) 6 | Ei$ [[:lower:]] \xe1 (0,1) 7 | E$ [[:upper:]] \xe1 NOMATCH 8 | Ei$ [[:upper:]] \xe1 (0,1) 9 | } 10 | -------------------------------------------------------------------------------- /tests/regex/datafiles/eucJP.dat: -------------------------------------------------------------------------------- 1 | {C ja_JP.eucJP 2 | E$ \xa3\xc1 \xa3\xc1 (0,2) 3 | E$ \xa3\xc1 \xa3\xc2 NOMATCH 4 | E$ [[:upper:]] \xa3\xc2 (0,2) 5 | Ei$ [[:upper:]] \xa3\xc2 (0,2) 6 | E$ [[:lower:]] \xa3\xc2 NOMATCH 7 | Ei$ [[:lower:]] \xa3\xc2 (0,2) 8 | E$ [\xa3\xc1-\xa3\xc3] \xa3\xc2 (0,2) 9 | } 10 | -------------------------------------------------------------------------------- /tests/strlcpy.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | T_DECL(strlcpy_PR_30745460, "Test return value of strlcpy(3)", 6 | T_META_CHECK_LEAKS(NO)) 7 | { 8 | char buf[1]; 9 | T_EXPECT_EQ(strlcpy(buf, "text", 1), 4UL, NULL); 10 | T_EXPECT_EQ(strlcpy(NULL, "text", 0), 4UL, NULL); 11 | } 12 | -------------------------------------------------------------------------------- /darwin/forceLibcToBuild.c: -------------------------------------------------------------------------------- 1 | // XCode will not build a library unless it contains at least one module. 2 | // Absent this requirement, libm.dylib would be composed entirely by linking 3 | // the component static libraries together, but to satisfy it, we must have 4 | // a C file. 5 | 6 | typedef int theCStandardDoesNotAllowAnEmptyModule; 7 | -------------------------------------------------------------------------------- /xcodescripts/force_libc_to_build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # force_libc_to_build.sh 4 | # Libc 5 | # 6 | # Created by Matt Wright on 10/4/11. 7 | # Copyright (c) 2011 None. All rights reserved. 8 | 9 | if [ "x$ACTION" == "xinstallhdrs" ]; then exit 0; fi 10 | 11 | DEPS_C="$BUILT_PRODUCTS_DIR/deps.c" 12 | 13 | [ -e "$DEPS_C" ] && rm -f "$DEPS_C" 14 | -------------------------------------------------------------------------------- /locale/FreeBSD/rune32.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is statically generated by running: 3 | * cc -arch i386 -D_LIBC_NO_FEATURE_VERIFICATION -DRUNEOFF32 -o rune32 locale/FreeBSD/rune.c 4 | */ 5 | 6 | #define SIZEOF32_RUNEENTRY 16 7 | #define SIZEOF32_RUNELOCALE 3164 8 | int off32[] = { 9 | 40, 10 | 44, 11 | 3124, 12 | 3128, 13 | 3132, 14 | 3136, 15 | 3140, 16 | 3144, 17 | 3148, 18 | 3160, 19 | 3164, 20 | }; 21 | -------------------------------------------------------------------------------- /xcodescripts/abort_unsupported.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | for platform in ${SUPPORTED_PLATFORMS} ; do 4 | [[ "${platform}" == "${PLATFORM_NAME}" ]] && exit 0 5 | done 6 | 7 | echo "Unsupported platform encountered:" >&2 8 | echo " PLATFORM_NAME: ${PLATFORM_NAME}" >&2 9 | echo " SUPPORTED_PLATFORMS: ${SUPPORTED_PLATFORMS}" >&2 10 | echo "Please contact the Darwin Runtime Team for help with your new platform bringup needs" >&2 11 | exit 1 12 | -------------------------------------------------------------------------------- /locale/FreeBSD/nomacros.c: -------------------------------------------------------------------------------- 1 | #include 2 | __FBSDID("$FreeBSD: src/lib/libc/locale/nomacros.c,v 1.5 2002/03/22 21:52:18 obrien Exp $"); 3 | 4 | /* 5 | * Tell to generate extern versions of all its inline 6 | * functions. The extern versions get called if the system doesn't 7 | * support inlines or the user defines _DONT_USE_CTYPE_INLINE_ 8 | * before including . 9 | */ 10 | #define _EXTERNALIZE_CTYPE_INLINES_ 11 | 12 | #include 13 | -------------------------------------------------------------------------------- /gen/FreeBSD/getprogname.c: -------------------------------------------------------------------------------- 1 | #include 2 | __FBSDID("$FreeBSD: src/lib/libc/gen/getprogname.c,v 1.4 2002/03/29 22:43:41 markm Exp $"); 3 | 4 | #include "namespace.h" 5 | #include 6 | #include 7 | #define __progname (*_NSGetProgname()) 8 | #include "un-namespace.h" 9 | 10 | #include "libc_private.h" 11 | 12 | __weak_reference(_getprogname, getprogname); 13 | 14 | const char * 15 | _getprogname(void) 16 | { 17 | 18 | return (__progname); 19 | } 20 | -------------------------------------------------------------------------------- /gdtoa/FreeBSD/gdtoa_fltrnds.h: -------------------------------------------------------------------------------- 1 | CONST FPI *fpi; 2 | FPI fpi1; 3 | int Rounding; 4 | #ifdef Trust_FLT_ROUNDS /*{{ only define this if FLT_ROUNDS really works! */ 5 | Rounding = Flt_Rounds; 6 | #else /*}{*/ 7 | Rounding = 1; 8 | switch(fegetround()) { 9 | case FE_TOWARDZERO: Rounding = 0; break; 10 | case FE_UPWARD: Rounding = 2; break; 11 | case FE_DOWNWARD: Rounding = 3; 12 | } 13 | #endif /*}}*/ 14 | fpi = &fpi0; 15 | if (Rounding != 1) { 16 | fpi1 = fpi0; 17 | fpi = &fpi1; 18 | fpi1.rounding = Rounding; 19 | } 20 | -------------------------------------------------------------------------------- /tests/timespec_get.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include 7 | 8 | T_DECL(timespec_get, "timespec_get") 9 | { 10 | struct timespec ts; 11 | T_ASSERT_EQ(timespec_get(&ts, TIME_UTC), TIME_UTC, NULL); 12 | 13 | struct timeval tv; 14 | T_ASSERT_POSIX_ZERO(gettimeofday(&tv, NULL), NULL); 15 | 16 | T_EXPECT_LE((unsigned long)tv.tv_sec - (unsigned long)ts.tv_sec, (unsigned long)1, 17 | "gettimeofday() should return same as timespec_get(TIME_UTC)"); 18 | } 19 | 20 | -------------------------------------------------------------------------------- /gen/__dirent.h: -------------------------------------------------------------------------------- 1 | /* 2 | * We need to prefix the elements of DIR with double-underscore to use 3 | * the implementation namespace. We could patch all the *dir.c code, 4 | * but it is easier to use #defines to rename the elements. This file 5 | * then gets included by all the *dir.c. 6 | */ 7 | #define dd_fd __dd_fd 8 | #define dd_loc __dd_loc 9 | #define dd_size __dd_size 10 | #define dd_buf __dd_buf 11 | #define dd_len __dd_len 12 | #define dd_seek __dd_seek 13 | #define dd_flags __dd_flags 14 | #define dd_lock __dd_lock 15 | #define dd_td __dd_td 16 | -------------------------------------------------------------------------------- /tests/regex/datafiles/5518392.dat: -------------------------------------------------------------------------------- 1 | E ((a)|(b))* ab (0,2)(1,2)(?,?)(1,2) 2 | E ((a)|(b))+ ab (0,2)(1,2)(?,?)(1,2) 3 | E ((a)|(b)){0,} ab (0,2)(1,2)(?,?)(1,2) 4 | E ((a)|(b)){1,} ab (0,2)(1,2)(?,?)(1,2) 5 | E ((a)|(b)){2} ab (0,2)(1,2)(?,?)(1,2) 6 | E ((a)|(b)){2,} ab (0,2)(1,2)(?,?)(1,2) 7 | E ((a)|(b)){0,2} ab (0,2)(1,2)(?,?)(1,2) 8 | E ((a)|(b)){1,2} ab (0,2)(1,2)(?,?)(1,2) 9 | E ((a)|(b)){2,2} ab (0,2)(1,2)(?,?)(1,2) 10 | E ((a)|(b)){0,10} ab (0,2)(1,2)(?,?)(1,2) 11 | E ((a)|(b)){1,10} ab (0,2)(1,2)(?,?)(1,2) 12 | E ((a)|(b)){2,10} ab (0,2)(1,2)(?,?)(1,2) 13 | -------------------------------------------------------------------------------- /tests/regex/datafiles/need-parenthesis.dat: -------------------------------------------------------------------------------- 1 | :RE#19:E a?((ab)?)(b?) ab (0,2)(1,1)(?,?)(1,2) 2 | :RE#19a:E (a?)((ab)?)(b?) ab (0,2)(0,1)(1,1)(?,?)(1,2) 3 | :RE#21:E a?((ab)?)b? ab (0,2)(1,1)(?,?) 4 | :RE#21a:E (a?)((ab)?)b? ab (0,2)(0,1)(1,1)(?,?) 5 | :RE#38:E .*(.*) xx (0,2)(2,2) 6 | :RE#38a:E (.*)(.*) xx (0,2)(0,2)(2,2) 7 | E (a?)((ab)?)(b?)a?(ab)?b? abab (0,4)(0,1)(1,1)(?,?)(1,2)(?,?) 8 | E (a?)((ab)?)(b?)(a?)(ab)?b? abab (0,4)(0,1)(1,1)(?,?)(1,2)(2,3)(?,?) 9 | E (a+?b*)((?:a|b)+) aaab BADRPT 10 | E ((a+?)(b*))((a|b)+) aaab BADRPT 11 | E ((a+?)b*)((?:a|b)+) aaab BADRPT 12 | -------------------------------------------------------------------------------- /stdlib/qsort_b.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #pragma clang diagnostic push 5 | #pragma clang diagnostic ignored "-Wimplicit-function-declaration" 6 | #pragma clang diagnostic ignored "-Wstrict-prototypes" 7 | #pragma clang diagnostic ignored "-Wint-conversion" 8 | 9 | typedef int cmp_t(const void *, const void *); 10 | 11 | void 12 | qsort_b(void *base, size_t nel, size_t width, cmp_t ^cmp_b) 13 | { 14 | void *cmp_f = ((struct Block_layout *)cmp_b)->invoke; 15 | qsort_r(base, nel, width, cmp_b, (void*)cmp_f); 16 | } 17 | #pragma clang diagnostic pop 18 | -------------------------------------------------------------------------------- /regex/TRE/lib/tre-compile.h: -------------------------------------------------------------------------------- 1 | /* 2 | tre-compile.h: Regex compilation definitions 3 | 4 | This software is released under a BSD-style license. 5 | See the file LICENSE for details and copyright. 6 | 7 | */ 8 | 9 | 10 | #ifndef TRE_COMPILE_H 11 | #define TRE_COMPILE_H 1 12 | 13 | typedef struct { 14 | int position; 15 | int code_min; 16 | int code_max; 17 | int *tags; 18 | int assertions; 19 | tre_bracket_match_list_t *bracket_match_list; 20 | int backref; 21 | int *params; 22 | locale_t loc; 23 | } tre_pos_and_tags_t; 24 | 25 | #endif /* TRE_COMPILE_H */ 26 | 27 | /* EOF */ 28 | -------------------------------------------------------------------------------- /tests/assumes_legacy.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | void os_crash_function(const char *message); 6 | 7 | static const char *expected_message = NULL; 8 | 9 | void os_crash_function(const char *message) { 10 | if (expected_message) { 11 | T_ASSERT_EQ_STR(message, expected_message, NULL); 12 | T_END; 13 | } else { 14 | T_PASS("Got crash message: %s", message); 15 | T_END; 16 | } 17 | } 18 | 19 | T_DECL(os_crash_sanity_legacy, "sanity check for os_crash") 20 | { 21 | expected_message = "My AWESOME assertion message."; 22 | os_crash(expected_message); 23 | } 24 | -------------------------------------------------------------------------------- /tests/regex/datafiles/UTF-8.dat: -------------------------------------------------------------------------------- 1 | {C en_US.UTF-8 2 | E$ \xce\x88 \xce\x88 (0,2) 3 | E$ \xce\x88 \xce\x89 NOMATCH 4 | E$ [[:upper:]] \xce\x89 (0,2) 5 | Ei$ [[:upper:]] \xce\x89 (0,2) 6 | E$ [[:lower:]] \xce\x89 NOMATCH 7 | Ei$ [[:lower:]] \xce\x89 (0,2) 8 | E$ [\xce\x88-\xce\x8a] \xce\x89 (0,2) 9 | E$ \xe1\xbc\x88 \xe1\xbc\x88 (0,3) 10 | E$ \xe1\xbc\x88 \xe1\xbc\x89 NOMATCH 11 | E$ [[:upper:]] \xe1\xbc\x89 (0,3) 12 | Ei$ [[:upper:]] \xe1\xbc\x89 (0,3) 13 | E$ [[:lower:]] \xe1\xbc\x89 NOMATCH 14 | Ei$ [[:lower:]] \xe1\xbc\x89 (0,3) 15 | E$ [\xe1\xbc\x88-\xe1\xbc\x8f] \xe1\xbc\x89 (0,3) 16 | } 17 | -------------------------------------------------------------------------------- /tests/regex/datafiles/tre-enhanced.dat: -------------------------------------------------------------------------------- 1 | ## Test \x in wide character under UTF-8 2 | {C en_US.UTF-8 3 | B$ \\x{263a} \xe2\x98\xba NOMATCH 4 | B$ SAME x{263a} (0,7) 5 | E$ \\x{263a} \xe2\x98\xba BADBR 6 | BE$ \\x81 \xc2\x81 NOMATCH 7 | BE$ SAME x81 (0,3) 8 | BE$H \\x{263a} \xe2\x98\xba (0,3) 9 | BE$H \\x81 \xc2\x81 (0,2) 10 | } 11 | ## Test non-self-contained options only apply to current subexpression 12 | E ((?i)fu)bar Fubar BADRPT 13 | E ((?i)fu)bar FuBar BADRPT 14 | EH ((?i)fu)bar Fubar (0,5)(0,2) 15 | EH ((?i)fu)bar FuBar NOMATCH 16 | EH (?:(?i)fu)bar Fubar (0,5) 17 | EH (?:(?i)fu)bar FuBar NOMATCH 18 | -------------------------------------------------------------------------------- /tests/regex/datafiles/conformance-vsc-ed.dat: -------------------------------------------------------------------------------- 1 | # vsc/tset/POSIX.cmd/ed/ed_02.ex 77 2 2 | B ^* a*c NOMATCH 3 | # vsc/tset/POSIX.cmd/ed/ed_02.ex 77 3 4 | B SAME ^*ab NOMATCH 5 | # vsc/tset/POSIX.cmd/ed/ed_02.ex 77 2 6 | B \(^*ab\) ^*ab NOMATCH 7 | # vsc/tset/POSIX.cmd/ed/ed_02.ex 77 3 8 | B \(^*b\) a*b NOMATCH 9 | # vsc/tset/POSIX.cmd/ed/ed_02.ex 77 4 10 | B \(^*b\) ^*b NOMATCH 11 | # vsc/tset/POSIX.cmd/ed/ed_06.ex 269 4 12 | B ^**9= ***9= (0,5) 13 | # vsc/tset/POSIX.cmd/ed/ed_08.ex 374 1 14 | BE \the the (0,3) 15 | BE$ \\the \the NOMATCH 16 | # vsc/tset/POSIX.cmd/ed/ed_10.ex 498 1 17 | BE fu\rthe\r further (0,7) 18 | -------------------------------------------------------------------------------- /tests/regex/datafiles/implementation_choices.dat: -------------------------------------------------------------------------------- 1 | BE \n n (0,1) 2 | BE [ [ EBRACK 3 | BE [[=e=]-z] x ERANGE 4 | BE a** a BADRPT 5 | E a*+ a BADRPT 6 | E a+* a BADRPT 7 | E a*? a BADRPT 8 | E a?* a BADRPT 9 | B *a *a (0,2) 10 | E *a a BADRPT 11 | B \(*a\) *a (0,2)(0,2) 12 | E (*a) a BADRPT 13 | B ^* * (0,1) 14 | E ^* a BADRPT 15 | E a|* a BADRPT 16 | E a| a EMPTY 17 | E |a a EMPTY 18 | E a||b a EMPTY 19 | B a\{3\} aaa (0,3) 20 | B a\{x a{x BADBR 21 | B a\{x\} a{x BADBR 22 | E a{x a{x (0,3) 23 | B a\($\) a (0,1)(1,1) 24 | B a\($\) a$ NOMATCH 25 | B a\($b\) a$b (0,3)(1,3) 26 | E a($) a (0,1)(1,1) 27 | E a($) a$ NOMATCH 28 | E a($b) a$b NOMATCH 29 | -------------------------------------------------------------------------------- /stdlib/FreeBSD/_Exit_.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is in the public domain. Written by Garrett A. Wollman, 3 | * 2002-09-07. 4 | * 5 | * $FreeBSD: src/lib/libc/stdlib/_Exit.c,v 1.1 2002/09/10 02:04:49 wollman Exp $ 6 | */ 7 | 8 | #include 9 | #include 10 | 11 | /* 12 | * ISO C99 added this function to provide for Standard C applications 13 | * which needed something like POSIX _exit(). A new interface was created 14 | * in case it turned out that _exit() was insufficient to meet the 15 | * requirements of ISO C. (That's probably not the case, but here 16 | * is where you would put the extra code if it were.) 17 | */ 18 | void 19 | _Exit(int code) 20 | { 21 | _exit(code); 22 | } 23 | -------------------------------------------------------------------------------- /tests/flockfile.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "darwintest.h" 5 | 6 | T_DECL(flockfile_preserve_errno, "flockfile preserves errno") 7 | { 8 | errno = EBUSY; 9 | flockfile(stderr); 10 | T_ASSERT_EQ(errno, EBUSY, "flockfile preserves errno"); 11 | } 12 | 13 | T_DECL(funlockfile_preserve_errno, "funlockfile preserves errno") 14 | { 15 | errno = EBUSY; 16 | funlockfile(stderr); 17 | T_ASSERT_EQ(errno, EBUSY, "funlockfile preserves errno"); 18 | } 19 | 20 | T_DECL(ftrylockfile_preserve_errno, "ftrylockfile preserves errno") 21 | { 22 | errno = EBUSY; 23 | ftrylockfile(stderr); 24 | T_ASSERT_EQ(errno, EBUSY, "ftrylockfile preserves errno"); 25 | } 26 | 27 | -------------------------------------------------------------------------------- /tests/regex/datafiles/rightassoc.dat: -------------------------------------------------------------------------------- 1 | NOTE left-assoc:pass-none right-assoc:pass-all : 2002-04-29 2 | 3 | E (a|ab)(c|bcd)(d*) abcd (0,4)(0,2)(2,3)(3,4) 4 | E (a|ab)(bcd|c)(d*) abcd (0,4)(0,2)(2,3)(3,4) 5 | E (ab|a)(c|bcd)(d*) abcd (0,4)(0,2)(2,3)(3,4) 6 | E (ab|a)(bcd|c)(d*) abcd (0,4)(0,2)(2,3)(3,4) 7 | 8 | E (a*)(b|abc)(c*) abc (0,3)(0,1)(1,2)(2,3) 9 | E (a*)(abc|b)(c*) abc (0,3)(0,1)(1,2)(2,3) 10 | E (a*)(b|abc)(c*) abc (0,3)(0,1)(1,2)(2,3) 11 | E (a*)(abc|b)(c*) abc (0,3)(0,1)(1,2)(2,3) 12 | 13 | E (a|ab)(c|bcd)(d|.*) abcd (0,4)(0,2)(2,3)(3,4) 14 | E (a|ab)(bcd|c)(d|.*) abcd (0,4)(0,2)(2,3)(3,4) 15 | E (ab|a)(c|bcd)(d|.*) abcd (0,4)(0,2)(2,3)(3,4) 16 | E (ab|a)(bcd|c)(d|.*) abcd (0,4)(0,2)(2,3)(3,4) 17 | -------------------------------------------------------------------------------- /locale/freelocale.3: -------------------------------------------------------------------------------- 1 | .Dd March 11, 2005 2 | .Dt FREELOCALE 3 3 | .Os 4 | .Sh NAME 5 | .Nm freelocale 6 | .Nd Frees an allocated locale 7 | .Sh SYNOPSIS 8 | .In xlocale.h 9 | .Ft int 10 | .Fn freelocale "locale_t loc" 11 | .Sh DESCRIPTION 12 | Frees the storage associated with 13 | .Va loc . 14 | Sub-structures have their reference counts reduced, 15 | and are freed if the reference count becomes zero. 16 | .Sh RETURN VALUES 17 | Returns zero on success, -1 on error. An error will occur if 18 | .Va loc 19 | is not a 20 | .Vt locale_t , 21 | or is 22 | .Dv NULL 23 | or 24 | .Dv LC_GLOBAL_LOCALE . 25 | .Sh SEE ALSO 26 | .Xr duplocale 3 , 27 | .Xr newlocale 3 , 28 | .Xr querylocale 3 , 29 | .Xr uselocale 3 , 30 | .Xr xlocale 3 31 | -------------------------------------------------------------------------------- /tests/regex/datafiles/misc.dat: -------------------------------------------------------------------------------- 1 | B \(a\)*\1 a NOMATCH 2 | #E (?l)(a*)(b|abc)(c*) abc (0,3)(0,0)(0,3)(3,3) 3 | E (...?.?)* xxxx (0,4)(0,4) 4 | E (...?.?)* xxxxx (0,5)(3,5) 5 | E (...?.?)* xxxxxx (0,6)(4,6) 6 | E (...?.?)* xxxxxxx (0,7)(4,7) 7 | E (...?.?)* xxxxxxxx (0,8)(4,8) 8 | E (...?.?)* xxxxxxxxx (0,9)(7,9) 9 | E (...?.?)* xxxxxxxxxx (0,10)(8,10) 10 | E (...?.?)* xxxxxxxxxxx (0,11)(8,11) 11 | {C en_GB.UTF-8 12 | E ^([[:digit:]]){3}$ abc NOMATCH 13 | } 14 | B \(a\(b\)*\)*\2 abab NOMATCH 15 | B a\(b\)*c\1 acb NOMATCH 16 | B a\(b\)*c\1 abbcbbb (0,5)(2,3) 17 | B a\(b\)*c\1 abbdbd NOMATCH 18 | E (a|ab)(bc|c) abcabc (0,3)(0,2)(2,3) 19 | :RE#33:E (aba|ab|a|z)* ababa (0,5)(2,5) 20 | :RE#33:E (aba|ab|a|(z))* ababa (0,5)(2,5) 21 | -------------------------------------------------------------------------------- /gen/FreeBSD/srand48.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1993 Martin Birgmeier 3 | * All rights reserved. 4 | * 5 | * You may redistribute unmodified or modified versions of this source 6 | * code provided that the above copyright notice and this and the 7 | * following conditions are retained. 8 | * 9 | * This software is provided ``as is'', and comes with no warranties 10 | * of any kind. I shall in no event be liable for anything that happens 11 | * to anyone/anything when using this software. 12 | */ 13 | 14 | #include "rand48.h" 15 | 16 | void 17 | srand48(long seed) 18 | { 19 | _rand48_seed = TOUINT48(RAND48_SEED_0, (unsigned short) seed, (unsigned short) (seed >> 16)); 20 | _rand48_mult = RAND48_MULT; 21 | _rand48_add = RAND48_ADD; 22 | } 23 | -------------------------------------------------------------------------------- /xcodescripts/alias.list: -------------------------------------------------------------------------------- 1 | __platform_bzero _bzero 2 | __platform_memccpy _memccpy 3 | __platform_memchr _memchr 4 | __platform_memcmp _memcmp 5 | __platform_memcmp _bcmp 6 | __platform_memmove _memmove 7 | __platform_memmove _memcpy 8 | __platform_memset _memset 9 | __platform_memset_pattern16 _memset_pattern16 10 | __platform_memset_pattern4 _memset_pattern4 11 | __platform_memset_pattern8 _memset_pattern8 12 | __platform_strchr _strchr 13 | __platform_strchr _index 14 | __platform_strcmp _strcmp 15 | __platform_strcpy _strcpy 16 | __platform_strlcat _strlcat 17 | __platform_strlcpy _strlcpy 18 | __platform_strlen _strlen 19 | __platform_strncmp _strncmp 20 | __platform_strncpy _strncpy 21 | __platform_strnlen _strnlen 22 | __platform_strstr _strstr 23 | -------------------------------------------------------------------------------- /locale/uselocale.3: -------------------------------------------------------------------------------- 1 | .Dd March 11, 2005 2 | .Dt USELOCALE 3 3 | .Os 4 | .Sh NAME 5 | .Nm uselocale 6 | .Nd Set the per-thread locale 7 | .Sh SYNOPSIS 8 | .In xlocale.h 9 | .Ft locale_t 10 | .Fn uselocale "locale_t loc" 11 | .Sh DESCRIPTION 12 | Sets the per-thread locale to 13 | .Va loc . 14 | Specify 15 | .Dv LC_GLOBAL_LOCALE 16 | to turn off any per-thread locale. 17 | Pass 18 | .Dv NULL 19 | to return the current value of the per-thread locale (or 20 | .Dv LC_GLOBAL_LOCALE ) 21 | without changing the locale. 22 | .Sh RETURN VALUES 23 | Returns the previous locale, or 24 | .Dv LC_GLOBAL_LOCALE 25 | if no per-thread locale was in effect. 26 | .Sh SEE ALSO 27 | .Xr duplocale 3 , 28 | .Xr freelocale 3 , 29 | .Xr newlocale 3 , 30 | .Xr querylocale 3 , 31 | .Xr xlocale 3 32 | -------------------------------------------------------------------------------- /gen/FreeBSD/_rand48.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1993 Martin Birgmeier 3 | * All rights reserved. 4 | * 5 | * You may redistribute unmodified or modified versions of this source 6 | * code provided that the above copyright notice and this and the 7 | * following conditions are retained. 8 | * 9 | * This software is provided ``as is'', and comes with no warranties 10 | * of any kind. I shall in no event be liable for anything that happens 11 | * to anyone/anything when using this software. 12 | */ 13 | 14 | #include 15 | __FBSDID("$FreeBSD: src/lib/libc/gen/_rand48.c,v 1.2 2002/03/22 21:52:05 obrien Exp $"); 16 | 17 | #include "rand48.h" 18 | 19 | uint48 _rand48_seed = RAND48_SEED; 20 | uint48 _rand48_mult = RAND48_MULT; 21 | uint48 _rand48_add = RAND48_ADD; 22 | -------------------------------------------------------------------------------- /xcodescripts/legacy_alias.list: -------------------------------------------------------------------------------- 1 | # (i386 only) 2 | # There used to be legacy versions of various funciotns, but we've removed them 3 | # and just given everyone the UNIX2003 behavior. The legacy variant doesn't 4 | # build those functions anymore, they are just aliased to corresponding 32-bit 5 | # non-legacy symbols. e.g.: 6 | # _opendir legacy, aliased to _opendir$UNIX2003 7 | # _opendir$UNIX2003 32-bit inodes 8 | # _opendir$INODE64$UNIX2003 64-bit inodes 9 | 10 | ___opendir2$UNIX2003 ___opendir2 11 | __seekdir$UNIX2003 __seekdir 12 | _closedir$UNIX2003 _closedir 13 | _fdopendir$UNIX2003 _fdopendir 14 | _opendir$UNIX2003 _opendir 15 | _rewinddir$UNIX2003 _rewinddir 16 | _seekdir$UNIX2003 _seekdir 17 | _telldir$UNIX2003 _telldir 18 | 19 | _strerror$UNIX2003 _strerror 20 | -------------------------------------------------------------------------------- /gen/FreeBSD/lrand48.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1993 Martin Birgmeier 3 | * All rights reserved. 4 | * 5 | * You may redistribute unmodified or modified versions of this source 6 | * code provided that the above copyright notice and this and the 7 | * following conditions are retained. 8 | * 9 | * This software is provided ``as is'', and comes with no warranties 10 | * of any kind. I shall in no event be liable for anything that happens 11 | * to anyone/anything when using this software. 12 | */ 13 | 14 | #include 15 | __FBSDID("$FreeBSD: src/lib/libc/gen/lrand48.c,v 1.2 2002/03/22 21:52:05 obrien Exp $"); 16 | 17 | #include "rand48.h" 18 | 19 | long 20 | lrand48(void) 21 | { 22 | _DORAND48(_rand48_seed); 23 | return (_rand48_seed >> 17) & 0x7fffffff; 24 | } 25 | -------------------------------------------------------------------------------- /gen/FreeBSD/drand48.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1993 Martin Birgmeier 3 | * All rights reserved. 4 | * 5 | * You may redistribute unmodified or modified versions of this source 6 | * code provided that the above copyright notice and this and the 7 | * following conditions are retained. 8 | * 9 | * This software is provided ``as is'', and comes with no warranties 10 | * of any kind. I shall in no event be liable for anything that happens 11 | * to anyone/anything when using this software. 12 | */ 13 | 14 | #include 15 | __FBSDID("$FreeBSD: src/lib/libc/gen/drand48.c,v 1.2 2002/03/22 21:52:05 obrien Exp $"); 16 | 17 | #include "rand48.h" 18 | 19 | double 20 | drand48(void) 21 | { 22 | ERAND48_BEGIN; 23 | _DORAND48(_rand48_seed); 24 | ERAND48_END(_rand48_seed); 25 | } 26 | -------------------------------------------------------------------------------- /gen/FreeBSD/mrand48.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1993 Martin Birgmeier 3 | * All rights reserved. 4 | * 5 | * You may redistribute unmodified or modified versions of this source 6 | * code provided that the above copyright notice and this and the 7 | * following conditions are retained. 8 | * 9 | * This software is provided ``as is'', and comes with no warranties 10 | * of any kind. I shall in no event be liable for anything that happens 11 | * to anyone/anything when using this software. 12 | */ 13 | 14 | #include 15 | __FBSDID("$FreeBSD: src/lib/libc/gen/mrand48.c,v 1.2 2002/03/22 21:52:05 obrien Exp $"); 16 | 17 | #include "rand48.h" 18 | 19 | long 20 | mrand48(void) 21 | { 22 | _DORAND48(_rand48_seed); 23 | return (int)((_rand48_seed >> 16) & 0xffffffff); 24 | } 25 | -------------------------------------------------------------------------------- /stdlib/FreeBSD/remque.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Initial implementation: 3 | * Copyright (c) 2002 Robert Drehmel 4 | * All rights reserved. 5 | * 6 | * As long as the above copyright statement and this notice remain 7 | * unchanged, you can do what ever you want with this file. 8 | */ 9 | #include 10 | __FBSDID("$FreeBSD: src/lib/libc/stdlib/remque.c,v 1.3 2003/01/04 07:34:41 tjr Exp $"); 11 | 12 | #define _SEARCH_PRIVATE 13 | #include 14 | #include /* for NULL */ 15 | 16 | void 17 | remque(void *element) 18 | { 19 | struct que_elem *prev, *next, *elem; 20 | 21 | elem = (struct que_elem *)element; 22 | 23 | prev = elem->prev; 24 | next = elem->next; 25 | 26 | if (prev != NULL) 27 | prev->next = next; 28 | if (next != NULL) 29 | next->prev = prev; 30 | } 31 | -------------------------------------------------------------------------------- /tests/err.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #define ITERATIONS 100 6 | 7 | T_DECL(err_multiple_exit_b, "Repeated set exit blocks doesn't leak copied blocks") 8 | { 9 | int __block num = 0; 10 | for (int i = 0; i < ITERATIONS; ++i) { 11 | err_set_exit_b(^(int j) { num += j; }); 12 | } 13 | err_set_exit_b(NULL); 14 | // Dummy expect is necessary to run leaks on this test. 15 | T_EXPECT_NULL(NULL, "DUMMY EXPECT"); 16 | } 17 | 18 | T_DECL(err_multiple_exit, "Setting exit w/o block after setting exit with block doesn't leak copied block") 19 | { 20 | int __block num = 0; 21 | err_set_exit_b(^(int j) { num += j; }); 22 | err_set_exit(NULL); 23 | // Dummy expect is necessary to run leaks on this test. 24 | T_EXPECT_NULL(NULL, "DUMMY EXPECT"); 25 | } 26 | -------------------------------------------------------------------------------- /locale/duplocale.3: -------------------------------------------------------------------------------- 1 | .Dd March 11, 2005 2 | .Dt DUPLOCALE 3 3 | .Os 4 | .Sh NAME 5 | .Nm duplocale 6 | .Nd Duplicate existing locale 7 | .Sh SYNOPSIS 8 | .In xlocale.h 9 | .Ft locale_t 10 | .Fn duplocale "locale_t loc" 11 | .Sh DESCRIPTION 12 | Duplicates an existing 13 | .Vt locale_t . 14 | Sub-structures are shared between the two 15 | .Vt locale_t 16 | structures. 17 | Passing 18 | .Dv NULL 19 | will duplicate the current locale. 20 | Passing 21 | .Dv LC_GLOBAL_LOCALE 22 | will duplicate the global locale. 23 | .Sh RETURN VALUES 24 | Returns a duplicated 25 | .Vt locale_t , 26 | or 27 | .Dv NULL 28 | on error. 29 | Duplicated locales should be freed with 30 | .Xr freelocale 3 . 31 | .Sh SEE ALSO 32 | .Xr freelocale 3 , 33 | .Xr newlocale 3 , 34 | .Xr querylocale 3 , 35 | .Xr uselocale 3 , 36 | .Xr xlocale 3 37 | -------------------------------------------------------------------------------- /gen/FreeBSD/nrand48.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1993 Martin Birgmeier 3 | * All rights reserved. 4 | * 5 | * You may redistribute unmodified or modified versions of this source 6 | * code provided that the above copyright notice and this and the 7 | * following conditions are retained. 8 | * 9 | * This software is provided ``as is'', and comes with no warranties 10 | * of any kind. I shall in no event be liable for anything that happens 11 | * to anyone/anything when using this software. 12 | */ 13 | 14 | #include 15 | __FBSDID("$FreeBSD: src/lib/libc/gen/nrand48.c,v 1.2 2002/03/22 21:52:05 obrien Exp $"); 16 | 17 | #include "rand48.h" 18 | 19 | long 20 | nrand48(unsigned short xseed[3]) 21 | { 22 | uint48 tmp; 23 | DORAND48(tmp, xseed); 24 | return (tmp >> 17) & 0x7fffffff; 25 | } 26 | -------------------------------------------------------------------------------- /gen/FreeBSD/erand48.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1993 Martin Birgmeier 3 | * All rights reserved. 4 | * 5 | * You may redistribute unmodified or modified versions of this source 6 | * code provided that the above copyright notice and this and the 7 | * following conditions are retained. 8 | * 9 | * This software is provided ``as is'', and comes with no warranties 10 | * of any kind. I shall in no event be liable for anything that happens 11 | * to anyone/anything when using this software. 12 | */ 13 | 14 | #include 15 | __FBSDID("$FreeBSD: src/lib/libc/gen/erand48.c,v 1.2 2002/03/22 21:52:05 obrien Exp $"); 16 | 17 | #include "rand48.h" 18 | 19 | double 20 | erand48(unsigned short xseed[3]) 21 | { 22 | uint48 tmp; 23 | ERAND48_BEGIN; 24 | DORAND48(tmp, xseed); 25 | ERAND48_END(tmp); 26 | } 27 | -------------------------------------------------------------------------------- /gen/FreeBSD/jrand48.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1993 Martin Birgmeier 3 | * All rights reserved. 4 | * 5 | * You may redistribute unmodified or modified versions of this source 6 | * code provided that the above copyright notice and this and the 7 | * following conditions are retained. 8 | * 9 | * This software is provided ``as is'', and comes with no warranties 10 | * of any kind. I shall in no event be liable for anything that happens 11 | * to anyone/anything when using this software. 12 | */ 13 | 14 | #include 15 | __FBSDID("$FreeBSD: src/lib/libc/gen/jrand48.c,v 1.2 2002/03/22 21:52:05 obrien Exp $"); 16 | 17 | #include "rand48.h" 18 | 19 | long 20 | jrand48(unsigned short xseed[3]) 21 | { 22 | uint48 tmp; 23 | DORAND48(tmp, xseed); 24 | return (int)((tmp >> 16) & 0xffffffff); 25 | } 26 | -------------------------------------------------------------------------------- /xcodescripts/sanitise_headers.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | # 3 | # Copyright (c) 2010-2011 Apple Inc. All rights reserved. 4 | # 5 | # @APPLE_APACHE_LICENSE_HEADER_START@ 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | # @APPLE_APACHE_LICENSE_HEADER_END@ 20 | # 21 | 22 | -------------------------------------------------------------------------------- /gen/FreeBSD/lcong48.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1993 Martin Birgmeier 3 | * All rights reserved. 4 | * 5 | * You may redistribute unmodified or modified versions of this source 6 | * code provided that the above copyright notice and this and the 7 | * following conditions are retained. 8 | * 9 | * This software is provided ``as is'', and comes with no warranties 10 | * of any kind. I shall in no event be liable for anything that happens 11 | * to anyone/anything when using this software. 12 | */ 13 | 14 | #include 15 | __FBSDID("$FreeBSD: src/lib/libc/gen/lcong48.c,v 1.2 2002/03/22 21:52:05 obrien Exp $"); 16 | 17 | #include "rand48.h" 18 | 19 | void 20 | lcong48(unsigned short p[7]) 21 | { 22 | LOADRAND48(_rand48_seed, &p[0]); 23 | LOADRAND48(_rand48_mult, &p[3]); 24 | _rand48_add = p[6]; 25 | } 26 | -------------------------------------------------------------------------------- /locale/querylocale.3: -------------------------------------------------------------------------------- 1 | .Dd March 11, 2005 2 | .Dt QUERYLOCALE 3 3 | .Os 4 | .Sh NAME 5 | .Nm querylocale 6 | .Nd Get locale name for a specified category 7 | .Sh SYNOPSIS 8 | .In xlocale.h 9 | .Ft const char * 10 | .Fn querylocale "int mask" "locale_t loc" 11 | .Sh DESCRIPTION 12 | Returns the name of the locale for the category specified by 13 | .Va mask . 14 | The 15 | .Va mask 16 | is scanned starting at the least significant bit, 17 | until the first set bit is found. This happens 18 | to scan the categories alphabetically, not 19 | including 20 | .Dv LC_ALL_MASK , 21 | but it is best to specify one category at a time. 22 | The available categories are documented in 23 | .Xr xlocale 3 24 | and 25 | .Xr newlocale 3 . 26 | .Sh SEE ALSO 27 | .Xr duplocale 3 , 28 | .Xr freelocale 3 , 29 | .Xr newlocale 3 , 30 | .Xr uselocale 3 , 31 | .Xr xlocale 3 32 | -------------------------------------------------------------------------------- /gen/FreeBSD/setprogname.c: -------------------------------------------------------------------------------- 1 | #include 2 | __FBSDID("$FreeBSD: src/lib/libc/gen/setprogname.c,v 1.8 2002/03/29 22:43:41 markm Exp $"); 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #define __progname (*_NSGetProgname()) 10 | 11 | #include "libc_private.h" 12 | 13 | void 14 | setprogname(const char *progname) 15 | { 16 | const char *p; 17 | char buf[2*MAXCOMLEN+1]; 18 | int mib[2]; 19 | 20 | p = strrchr(progname, '/'); 21 | if (p != NULL) 22 | __progname = (char *)(p = p + 1); 23 | else 24 | __progname = (char *)(p = progname); 25 | 26 | strlcpy(&buf[0], (char *)(p), sizeof(buf)); 27 | 28 | mib[0] = CTL_KERN; 29 | mib[1] = KERN_PROCNAME; 30 | 31 | /* ignore errors as this is not a hard error */ 32 | sysctl(mib, 2, NULL, NULL, &buf[0], strlen(buf)); 33 | } 34 | -------------------------------------------------------------------------------- /gdtoa/gd_qnan.h: -------------------------------------------------------------------------------- 1 | #if defined(__ppc__) || defined(__ppc64__) 2 | 3 | #define f_QNAN 0x7fc00000 4 | #define d_QNAN0 0x7ff80000 5 | #define d_QNAN1 0x0 6 | #define ld_QNAN0 0x7ff80000 7 | #define ld_QNAN1 0x0 8 | #define ld_QNAN2 0x0 9 | #define ld_QNAN3 0x0 10 | #define ldus_QNAN0 0x7ff8 11 | #define ldus_QNAN1 0x0 12 | #define ldus_QNAN2 0x0 13 | #define ldus_QNAN3 0x0 14 | #define ldus_QNAN4 0x0 15 | 16 | #elif defined(__i386__) || defined(__x86_64__) || defined(__arm__) || defined(__arm64__) 17 | 18 | #define f_QNAN 0x7fc00000 19 | #define d_QNAN0 0x0 20 | #define d_QNAN1 0x7ff80000 21 | #define ld_QNAN0 0x0 22 | #define ld_QNAN1 0xc0000000 23 | #define ld_QNAN2 0x7fff 24 | #define ld_QNAN3 0x0 25 | #define ldus_QNAN0 0x0 26 | #define ldus_QNAN1 0x0 27 | #define ldus_QNAN2 0x0 28 | #define ldus_QNAN3 0xc000 29 | #define ldus_QNAN4 0x7fff 30 | 31 | #else 32 | #error unknown architecture 33 | #endif 34 | -------------------------------------------------------------------------------- /gen/FreeBSD/seed48.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1993 Martin Birgmeier 3 | * All rights reserved. 4 | * 5 | * You may redistribute unmodified or modified versions of this source 6 | * code provided that the above copyright notice and this and the 7 | * following conditions are retained. 8 | * 9 | * This software is provided ``as is'', and comes with no warranties 10 | * of any kind. I shall in no event be liable for anything that happens 11 | * to anyone/anything when using this software. 12 | */ 13 | 14 | #include 15 | __FBSDID("$FreeBSD: src/lib/libc/gen/seed48.c,v 1.2 2002/03/22 21:52:05 obrien Exp $"); 16 | 17 | #include "rand48.h" 18 | 19 | unsigned short * 20 | seed48(unsigned short xseed[3]) 21 | { 22 | static unsigned short sseed[3]; 23 | 24 | STORERAND48(_rand48_seed, sseed); 25 | LOADRAND48(_rand48_seed, xseed); 26 | _rand48_mult = RAND48_MULT; 27 | _rand48_add = RAND48_ADD; 28 | return sseed; 29 | } 30 | -------------------------------------------------------------------------------- /tests/regex/datafiles/14189743.dat: -------------------------------------------------------------------------------- 1 | #Ei ^((([[:alnum:]_][[:alnum:]-]{0,61})?[[:alnum:]]\.)*)([[:alnum:]_][[:alnum:]-]{0,61})?[[:alnum:]]$ nssnssnssnssnssnssnssnssnssnssnssnssnss.edu (0,1) 2 | Ei ^((([[:alnum:]_][[:alnum:]-]{0,61})?[[:alnum:]]\.)*)([[:alnum:]_][[:alnum:]-]{0,61})?[[:alnum:]]$ nssnssnssnssnssnssnssnssnssnssnssnssnssnssnssnssnssnssnssnssnssnss.edu (0,1) 3 | Ei SAME ssnssnssnssnssnssnssnssnssnssnssnssnssnssnssnssnssnssnssnssnssnss.edu (0,1) 4 | Ei SAME snssnssnssnssnssnssnssnssnssnssnssnssnssnssnssnssnssnssnssnssnss.edu (0,1) 5 | Ei SAME nssnssnssnssnssnssnssnssnssnssnssnssnssnssnssnssnssnssnssnssnss.edu (0,1) 6 | Ei SAME ssnssnssnssnssnssnssnssnssnssnssnssnssnssnssnssnssnssnssnssnss.edu (0,1) 7 | Ei SAME snssnssnssnssnssnssnssnssnssnssnssnssnssnssnssnssnssnssnssnss.edu (0,1) 8 | Ei SAME nssnssnssnssnssnssnssnssnssnssnssnssnssnssnssnssnssnssnssnss.edu (0,1) 9 | Ei SAME ssnssnssnssnssnssnssnssnssnssnssnssnssnssnssnssnssnssnssnss.edu (0,1) 10 | -------------------------------------------------------------------------------- /tests/readpassphrase.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | #include 5 | 6 | T_DECL(readpassphrase_stdin, "readpassphrase_stdin") 7 | { 8 | int stdin_pipe[2] = { 0 }; 9 | char pwd[] = "ishouldnotbedoingthis\n"; 10 | char buff[128]; 11 | 12 | T_ASSERT_POSIX_ZERO(pipe(stdin_pipe), 13 | "must be able to create a pipe"); 14 | T_ASSERT_EQ(STDIN_FILENO, dup2(stdin_pipe[0], STDIN_FILENO), 15 | "must be able to re-register the read end of the pipe with STDIN_FILENO"); 16 | T_ASSERT_EQ((ssize_t) sizeof(pwd), write(stdin_pipe[1], pwd, sizeof(pwd)), 17 | "must be able to write into the pipe"); 18 | T_ASSERT_EQ((void *) buff, (void *) readpassphrase("", buff, sizeof(buff), RPP_STDIN), 19 | "readpassphrase must return its buffer argument on success"); 20 | // readpassphrase eats newlines 21 | pwd[sizeof(pwd) - 2] = 0; 22 | T_ASSERT_EQ_STR(buff, pwd, 23 | "readpassphrase with RPP_STDIN must capture stdin"); 24 | } 25 | 26 | -------------------------------------------------------------------------------- /tests/wchar.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include 7 | 8 | /* 9 | * Test courtesy of Roel Standaert 10 | * Source: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=209907 11 | */ 12 | T_DECL(wchar_PR_26556792, "wcsrtombs neglects to set src pointer on EILSEQ error") 13 | { 14 | char out[64]; 15 | wchar_t *in = L"Hello! \x20AC Hello!"; 16 | const wchar_t *inptr = in; 17 | mbstate_t state = {{0}}; 18 | 19 | T_ASSERT_EQ((size_t)-1, wcsrtombs(out, &inptr, sizeof(out), &state), NULL); 20 | T_EXPECT_EQ((long)(inptr - in), (long)7, NULL); 21 | } 22 | 23 | 24 | T_DECL(wchar_PR_26828480, "double free in __vfwprintf") 25 | { 26 | wchar_t *test; 27 | int ret; 28 | 29 | test = (wchar_t *) malloc(512 * sizeof(wchar_t)); 30 | ret = swprintf(test, 512, L"%a, %s\n", 3.14, (char *) NULL); 31 | 32 | free(test); 33 | T_ASSERT_GT(ret, 0, "swprintf"); 34 | } 35 | -------------------------------------------------------------------------------- /stdlib/a64l.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Written by J.T. Conklin . 3 | * Public domain. 4 | */ 5 | 6 | #if defined(LIBC_SCCS) && !defined(lint) 7 | static char *rcsid = "$OpenBSD: a64l.c,v 1.3 1997/08/17 22:58:34 millert Exp $"; 8 | #endif /* LIBC_SCCS and not lint */ 9 | 10 | #include 11 | #include 12 | 13 | long 14 | a64l(s) 15 | const char *s; 16 | { 17 | int value, digit, shift; 18 | int i; 19 | 20 | if (s == NULL) { 21 | errno = EINVAL; 22 | return(-1L); 23 | } 24 | 25 | value = 0; 26 | shift = 0; 27 | for (i = 0; *s && i < 6; i++, s++) { 28 | if (*s >= '.' && *s <= '/') 29 | digit = *s - '.'; 30 | else if (*s >= '0' && *s <= '9') 31 | digit = *s - '0' + 2; 32 | else if (*s >= 'A' && *s <= 'Z') 33 | digit = *s - 'A' + 12; 34 | else if (*s >= 'a' && *s <= 'z') 35 | digit = *s - 'a' + 38; 36 | else { 37 | errno = EINVAL; 38 | return(-1L); 39 | } 40 | 41 | value |= digit << shift; 42 | shift += 6; 43 | } 44 | 45 | return(value); 46 | } 47 | 48 | -------------------------------------------------------------------------------- /xcodescripts/libc_static.xcconfig: -------------------------------------------------------------------------------- 1 | #include "libc.xcconfig" 2 | 3 | BUILD_ARCHIVES = Base FreeBSD TRE vCancelable vDarwinExtsn 4 | BUILD_VARIANTS = normal debug 5 | EXECUTABLE_PREFIX = lib 6 | INSTALL_PATH = /usr/local/lib/system 7 | OTHER_LIBTOOLFLAGS = -filelist $(BUILT_PRODUCTS_DIR)/$(CURRENT_VARIANT).linklist.libtool 8 | PRODUCT_NAME = c 9 | SKIP_INSTALL = NO 10 | STRIP_INSTALLED_PRODUCT = NO 11 | VARIANT = STATIC_VERSION 12 | VERSIONING_SYSTEM = apple-generic 13 | 14 | // Only include what's needed 15 | EXCLUDED_SOURCE_FILE_NAMES = * 16 | INCLUDED_SOURCE_FILE_NAMES = secure/*.c $(ARCH_FAMILY_$(CURRENT_ARCH))/*/*.c $(ARCH_FAMILY_$(CURRENT_ARCH))/*/*.S $(ARCH_FAMILY_$(CURRENT_ARCH))/*/*.s 17 | 18 | VARIANT_PREPROCESSOR_MACROS = -UBUILDING_VARIANT -DVARIANT_STATIC -DVARIANT_CANCELABLE -DVARIANT_DARWINEXTSN -U__DARWIN_NON_CANCELABLE -D__DARWIN_NON_CANCELABLE=0 19 | 20 | SYSTEM_FRAMEWORK_HEADERS = $(DERIVED_FILES_DIR)/System.framework/Versions/B/PrivateHeaders 21 | HEADER_SEARCH_PATHS = $(FreeBSD_SEARCH_PATHS) $(inherited) 22 | -------------------------------------------------------------------------------- /darwin/atexit_receipt.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014 Apple Computer, Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | -------------------------------------------------------------------------------- /include/fcntl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | #include 24 | -------------------------------------------------------------------------------- /include/errno.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | #include 24 | 25 | -------------------------------------------------------------------------------- /include/syslog.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | #include 24 | 25 | -------------------------------------------------------------------------------- /include/poll.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004 Apple Computer, Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | #include 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /fbsdcompat/namespace.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2003 Apple Computer, Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | /* 24 | * This file left intentionally blank 25 | */ 26 | -------------------------------------------------------------------------------- /nbsdcompat/namespace.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004 Apple Computer, Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | /* 24 | * This file left intentionally blank 25 | */ 26 | -------------------------------------------------------------------------------- /fbsdcompat/machine/atomic.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2003 Apple Computer, Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | /* 24 | * This file left intentionally blank. 25 | */ 26 | -------------------------------------------------------------------------------- /fbsdcompat/un-namespace.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2003 Apple Computer, Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | /* 24 | * This file left intentionally blank 25 | */ 26 | -------------------------------------------------------------------------------- /tests/locale.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | 10 | T_DECL(locale_PR_23679075, "converts a cyrillic a to uppercase") 11 | { 12 | locale_t loc = newlocale(LC_COLLATE_MASK|LC_CTYPE_MASK, "ru_RU", 0); 13 | T_ASSERT_NOTNULL(loc, "newlocale(LC_COLLATE_MASK|LC_CTYPE_MASK, \"ru_RU\", 0) should return a locale"); 14 | 15 | T_ASSERT_EQ(towupper_l(0x0430, loc), 0x0410, NULL); 16 | freelocale(loc); 17 | } 18 | 19 | T_DECL(locale_PR_24165555, "swprintf with Russian chars") 20 | { 21 | setlocale(LC_ALL, "ru_RU.UTF-8"); 22 | 23 | wchar_t buffer[256]; 24 | T_EXPECT_POSIX_SUCCESS(swprintf(buffer, 256, L"%ls", L"English: Hello World"), "English"); 25 | T_EXPECT_POSIX_SUCCESS(swprintf(buffer, 256, L"%ls", L"Russian: ру́сский язы́к"), "Russian"); 26 | 27 | setlocale(LC_ALL, ""); 28 | } 29 | 30 | T_DECL(locale_PR_28774201, "return code on bad locale") 31 | { 32 | T_EXPECT_NULL(newlocale(LC_COLLATE_MASK | LC_CTYPE_MASK, "foobar", NULL), NULL); 33 | T_EXPECT_EQ(errno, ENOENT, NULL); 34 | } 35 | -------------------------------------------------------------------------------- /stdlib/l64a.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Written by J.T. Conklin . 3 | * Public domain. 4 | */ 5 | 6 | #if defined(LIBC_SCCS) && !defined(lint) 7 | static char *rcsid = "$OpenBSD: l64a.c,v 1.3 1997/08/17 22:58:34 millert Exp $"; 8 | #endif /* LIBC_SCCS and not lint */ 9 | 10 | #include 11 | #include 12 | 13 | char * 14 | #ifdef __LP64__ 15 | l64a(v) 16 | long v; 17 | #else /* !__LP64__ */ 18 | l64a(value) 19 | long value; 20 | #endif /* __LP64__ */ 21 | { 22 | static char buf[8]; 23 | #ifdef __LP64__ 24 | int value = v; 25 | #endif /* __LP64__ */ 26 | char *s = buf; 27 | int digit; 28 | int i; 29 | 30 | #ifndef __LP64__ 31 | if (value < 0) { 32 | errno = EINVAL; 33 | return(NULL); 34 | } 35 | #endif /* __LP64__ */ 36 | 37 | for (i = 0; value != 0 && i < 6; i++) { 38 | digit = value & 0x3f; 39 | 40 | if (digit < 2) 41 | *s = digit + '.'; 42 | else if (digit < 12) 43 | *s = digit + '0' - 2; 44 | else if (digit < 38) 45 | *s = digit + 'A' - 12; 46 | else 47 | *s = digit + 'a' - 38; 48 | 49 | value >>= 6; 50 | s++; 51 | } 52 | 53 | *s = '\0'; 54 | 55 | return(buf); 56 | } 57 | 58 | -------------------------------------------------------------------------------- /tests/assumes.c: -------------------------------------------------------------------------------- 1 | #define OS_CRASH_ENABLE_EXPERIMENTAL_LIBTRACE 1 2 | #include 3 | 4 | #include 5 | 6 | void os_crash_function(const char *message); 7 | 8 | static const char *expected_message = NULL; 9 | 10 | void os_crash_function(const char *message) { 11 | if (expected_message) { 12 | T_ASSERT_EQ_STR(message, expected_message, NULL); 13 | T_END; 14 | } else { 15 | T_PASS("Got crash message: %s", message); 16 | T_END; 17 | } 18 | } 19 | 20 | T_DECL(os_crash_sanity, "sanity check for os_crash") 21 | { 22 | expected_message = "My AWESOME assertion message."; 23 | os_crash(expected_message); 24 | } 25 | 26 | extern int two; 27 | int two = 2; 28 | 29 | T_DECL(os_assert_no_msg, "sanity check for os_assert w/o a message") 30 | { 31 | expected_message = "assertion failure: \"two + two == 5\" -> %lld"; 32 | os_assert(two + two == 5); 33 | } 34 | 35 | #define DOGMA "Today, we celebrate the first glorious anniversary of the Information Purification Directives." 36 | T_DECL(os_assert_msg, "sanity check for os_assert with a message") 37 | { 38 | expected_message = "assertion failure: " DOGMA; 39 | os_assert(two + two == 5, DOGMA); 40 | } 41 | -------------------------------------------------------------------------------- /include/_ctermid.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2000, 2002-2006, 2008-2010, 2012 Apple Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | #ifndef _CTERMID_H_ 25 | #define _CTERMID_H_ 26 | char *ctermid(char *); 27 | #endif 28 | -------------------------------------------------------------------------------- /fbsdcompat/sys/endian.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2003 Apple Computer, Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | #ifndef _SYS_ENDIAN_H_ 24 | #define _SYS_ENDIAN_H_ 25 | #include 26 | #endif /* _SYS_ENDIAN_H_ */ 27 | -------------------------------------------------------------------------------- /emulated/lchflags.3: -------------------------------------------------------------------------------- 1 | .Dd Oct 31, 2005 2 | .Dt LCHFLAGS 3 3 | .Os 4 | .Sh NAME 5 | .Nm lchflags 6 | .Nd set file flags 7 | .Sh SYNOPSIS 8 | .In sys/stat.h 9 | .In unistd.h 10 | .Ft int 11 | .Fn lchflags "const char *path" "u_int flags" 12 | .Sh DESCRIPTION 13 | The file whose name is given by 14 | .Fa path 15 | has its flags changed to 16 | .Fa flags . 17 | See 18 | .Xr chflags 2 19 | for the values of the 20 | .Fa flags . 21 | .Pp 22 | The 23 | .Fn lchflags 24 | call is like 25 | .Fn chflags 26 | except when the named file is a symbolic link, 27 | in which case 28 | .Fn lchflags 29 | will change the flags of the link itself, 30 | rather than the file it points to. 31 | .Sh NOTE 32 | Instead of being a system call, 33 | .Fn lchflags 34 | is emulated using 35 | .Xr setattrlist 2 . 36 | Not all file systems support 37 | .Xr setattrlist 2 . 38 | .Sh RETURN VALUES 39 | Upon successful completion, a value of 0 is returned. 40 | Otherwise, -1 is returned and the global variable 41 | .Va errno 42 | is set to indicate the error. 43 | .Sh ERRORS 44 | The 45 | .Fn lchflags 46 | call may return the same errors as 47 | .Xr chflags 2 48 | and 49 | .Xr setattrlist 2 . 50 | .Sh SEE ALSO 51 | .Xr chflags 2 , 52 | .Xr setattrlist 2 53 | -------------------------------------------------------------------------------- /string/bcopy.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Apple, Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | #include 25 | 26 | void bcopy(const void *src, void *dst, size_t n) { 27 | _platform_memmove(dst, src, n); 28 | } 29 | -------------------------------------------------------------------------------- /stdlib/FreeBSD/insque.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Initial implementation: 3 | * Copyright (c) 2002 Robert Drehmel 4 | * All rights reserved. 5 | * 6 | * As long as the above copyright statement and this notice remain 7 | * unchanged, you can do what ever you want with this file. 8 | */ 9 | #include 10 | __FBSDID("$FreeBSD: src/lib/libc/stdlib/insque.c,v 1.3 2003/01/04 07:34:41 tjr Exp $"); 11 | 12 | #define _SEARCH_PRIVATE 13 | #include 14 | #ifdef DEBUG 15 | #include 16 | #else 17 | #include /* for NULL */ 18 | #endif 19 | 20 | void 21 | insque(void *element, void *pred) 22 | { 23 | struct que_elem *prev, *next, *elem; 24 | 25 | elem = (struct que_elem *)element; 26 | prev = (struct que_elem *)pred; 27 | 28 | if (prev == NULL) { 29 | elem->prev = elem->next = NULL; 30 | return; 31 | } 32 | 33 | next = prev->next; 34 | if (next != NULL) { 35 | #ifdef DEBUG 36 | if (next->prev != prev) { 37 | fprintf(stderr, "insque: Inconsistency detected:" 38 | " next(%p)->prev(%p) != prev(%p)\n", 39 | next, next->prev, prev); 40 | } 41 | #endif 42 | next->prev = elem; 43 | } 44 | prev->next = elem; 45 | elem->prev = prev; 46 | elem->next = next; 47 | } 48 | -------------------------------------------------------------------------------- /emulated/lchmod.3: -------------------------------------------------------------------------------- 1 | .Dd Oct 31, 2005 2 | .Dt LCHMOD 3 3 | .Os 4 | .Sh NAME 5 | .Nm lchmod 6 | .Nd change mode of file 7 | .Sh SYNOPSIS 8 | .In sys/stat.h 9 | .In unistd.h 10 | .Ft int 11 | .Fn lchmod "const char *path" "mode_t flags" 12 | .Sh DESCRIPTION 13 | The function 14 | .Fn lchmod 15 | sets the file permission bits of the file specified by the pathname 16 | .Fa path 17 | to 18 | .Fa mode . 19 | See 20 | .Xr chmod 2 21 | for the values of the 22 | .Fa flags . 23 | .Pp 24 | The 25 | .Fn lchmod 26 | call is like 27 | .Fn chmod 28 | except when the named file is a symbolic link, 29 | in which case 30 | .Fn lchmod 31 | will change the flags of the link itself, 32 | rather than the file it points to. 33 | .Sh NOTE 34 | Instead of being a system call, 35 | .Fn lchmod 36 | is emulated using 37 | .Xr setattrlist 2 . 38 | Not all file systems support 39 | .Xr setattrlist 2 . 40 | .Sh RETURN VALUES 41 | Upon successful completion, a value of 0 is returned. 42 | Otherwise, -1 is returned and the global variable 43 | .Va errno 44 | is set to indicate the error. 45 | .Sh ERRORS 46 | The 47 | .Fn lchmod 48 | call may return the same errors as 49 | .Xr chmod 2 50 | and 51 | .Xr setattrlist 2 . 52 | .Sh SEE ALSO 53 | .Xr chmod 2 , 54 | .Xr setattrlist 2 55 | -------------------------------------------------------------------------------- /Platforms/appletvos/Makefile.inc: -------------------------------------------------------------------------------- 1 | # 2 | # Selectable features for AppleTV 3 | # 4 | 5 | # Legacy *64 APIs 6 | #FEATURE_LEGACY_64_APIS = 1 7 | 8 | # Legacy crt1.o environ support 9 | #FEATURE_LEGACY_CRT1_ENVIRON = 1 10 | 11 | # Legacy rune APIs 12 | #FEATURE_LEGACY_RUNE_APIS = 1 13 | 14 | # Legacy utmp APIs 15 | #FEATURE_LEGACY_UTMP_APIS = 1 16 | 17 | # OSThermalNotification APIs 18 | FEATURE_THERM_NOTIFICATION_APIS = 1 19 | 20 | # No pre-1050 variants (should match sys/cdefs.h) 21 | FEATURE_ONLY_1050_VARIANTS = 1 22 | 23 | # No legacy variants (should match sys/cdefs.h) 24 | FEATURE_ONLY_UNIX_CONFORMANCE = 1 25 | 26 | # Only 64-bit ino_t (should match sys/cdefs.h) 27 | FEATURE_ONLY_64_BIT_INO_T = 1 28 | 29 | # Patch 3333969 30 | #FEATURE_PATCH_3333969 = 1 31 | 32 | # Patch 3417676 33 | #FEATURE_PATCH_3417676 = 1 34 | 35 | # plockstat dtrace support 36 | #FEATURE_PLOCKSTAT = 1 37 | 38 | # Timezone change notification 39 | FEATURE_TIMEZONE_CHANGE_NOTIFICATION = 1 40 | 41 | # Smaller stdio buffers 42 | FEATURE_SMALL_STDIOBUF = 1 43 | 44 | # Disable registration of specific signals () 45 | FEATURE_SIGNAL_RESTRICTION = 1 46 | 47 | # Enable 32-bit compilation in unistd.h () 48 | # FEATURE_POSIX_ILP32_ALLOW = 0 49 | -------------------------------------------------------------------------------- /Platforms/bridgeos/Makefile.inc: -------------------------------------------------------------------------------- 1 | # 2 | # Selectable features for bridgeOS 3 | # 4 | 5 | # Legacy *64 APIs 6 | #FEATURE_LEGACY_64_APIS = 1 7 | 8 | # Legacy crt1.o environ support 9 | #FEATURE_LEGACY_CRT1_ENVIRON = 1 10 | 11 | # Legacy rune APIs 12 | #FEATURE_LEGACY_RUNE_APIS = 1 13 | 14 | # Legacy utmp APIs 15 | #FEATURE_LEGACY_UTMP_APIS = 1 16 | 17 | # OSThermalNotification APIs 18 | FEATURE_THERM_NOTIFICATION_APIS = 1 19 | 20 | # No pre-1050 variants (should match sys/cdefs.h) 21 | FEATURE_ONLY_1050_VARIANTS = 1 22 | 23 | # No legacy variants (should match sys/cdefs.h) 24 | FEATURE_ONLY_UNIX_CONFORMANCE = 1 25 | 26 | # Only 64-bit ino_t (should match sys/cdefs.h) 27 | FEATURE_ONLY_64_BIT_INO_T = 1 28 | 29 | # Patch 3333969 30 | #FEATURE_PATCH_3333969 = 1 31 | 32 | # Patch 3417676 33 | #FEATURE_PATCH_3417676 = 1 34 | 35 | # plockstat dtrace support 36 | #FEATURE_PLOCKSTAT = 1 37 | 38 | # Timezone change notification 39 | FEATURE_TIMEZONE_CHANGE_NOTIFICATION = 1 40 | 41 | # Smaller stdio buffers 42 | FEATURE_SMALL_STDIOBUF = 1 43 | 44 | # Disable registration of specific signals () 45 | FEATURE_SIGNAL_RESTRICTION = 1 46 | 47 | # Enable 32-bit compilation in unistd.h () 48 | # FEATURE_POSIX_ILP32_ALLOW = 0 49 | -------------------------------------------------------------------------------- /Platforms/iphoneos/Makefile.inc: -------------------------------------------------------------------------------- 1 | # 2 | # Selectable features for iPhone 3 | # 4 | 5 | # Legacy *64 APIs 6 | #FEATURE_LEGACY_64_APIS = 1 7 | 8 | # Legacy crt1.o environ support 9 | #FEATURE_LEGACY_CRT1_ENVIRON = 1 10 | 11 | # Legacy rune APIs 12 | #FEATURE_LEGACY_RUNE_APIS = 1 13 | 14 | # Legacy utmp APIs 15 | #FEATURE_LEGACY_UTMP_APIS = 1 16 | 17 | # OSThermalNotification APIs 18 | FEATURE_THERM_NOTIFICATION_APIS = 1 19 | 20 | # No pre-1050 variants (should match sys/cdefs.h) 21 | FEATURE_ONLY_1050_VARIANTS = 1 22 | 23 | # No legacy variants (should match sys/cdefs.h) 24 | FEATURE_ONLY_UNIX_CONFORMANCE = 1 25 | 26 | # Only 64-bit ino_t (should match sys/cdefs.h) 27 | FEATURE_ONLY_64_BIT_INO_T = 1 28 | 29 | # Patch 3333969 30 | #FEATURE_PATCH_3333969 = 1 31 | 32 | # Patch 3417676 33 | #FEATURE_PATCH_3417676 = 1 34 | 35 | # plockstat dtrace support 36 | #FEATURE_PLOCKSTAT = 1 37 | 38 | # Timezone change notification 39 | FEATURE_TIMEZONE_CHANGE_NOTIFICATION = 1 40 | 41 | # Smaller stdio buffers 42 | FEATURE_SMALL_STDIOBUF = 1 43 | 44 | # Disable registration of specific signals () 45 | # FEATURE_SIGNAL_RESTRICTION = 0 46 | 47 | # Enable 32-bit compilation in unistd.h () 48 | # FEATURE_POSIX_ILP32_ALLOW = 0 49 | -------------------------------------------------------------------------------- /Platforms/watchos/Makefile.inc: -------------------------------------------------------------------------------- 1 | # 2 | # Selectable features for Apple Watch 3 | # 4 | 5 | # Legacy *64 APIs 6 | #FEATURE_LEGACY_64_APIS = 1 7 | 8 | # Legacy crt1.o environ support 9 | #FEATURE_LEGACY_CRT1_ENVIRON = 1 10 | 11 | # Legacy rune APIs 12 | #FEATURE_LEGACY_RUNE_APIS = 1 13 | 14 | # Legacy utmp APIs 15 | #FEATURE_LEGACY_UTMP_APIS = 1 16 | 17 | # OSThermalNotification APIs 18 | FEATURE_THERM_NOTIFICATION_APIS = 1 19 | 20 | # No pre-1050 variants (should match sys/cdefs.h) 21 | FEATURE_ONLY_1050_VARIANTS = 1 22 | 23 | # No legacy variants (should match sys/cdefs.h) 24 | FEATURE_ONLY_UNIX_CONFORMANCE = 1 25 | 26 | # Only 64-bit ino_t (should match sys/cdefs.h) 27 | FEATURE_ONLY_64_BIT_INO_T = 1 28 | 29 | # Patch 3333969 30 | #FEATURE_PATCH_3333969 = 1 31 | 32 | # Patch 3417676 33 | #FEATURE_PATCH_3417676 = 1 34 | 35 | # plockstat dtrace support 36 | #FEATURE_PLOCKSTAT = 1 37 | 38 | # Timezone change notification 39 | FEATURE_TIMEZONE_CHANGE_NOTIFICATION = 1 40 | 41 | # Smaller stdio buffers 42 | FEATURE_SMALL_STDIOBUF = 1 43 | 44 | # Disable registration of specific signals () 45 | FEATURE_SIGNAL_RESTRICTION = 1 46 | 47 | # Enable 32-bit compilation in unistd.h () 48 | FEATURE_POSIX_ILP32_ALLOW = 1 49 | -------------------------------------------------------------------------------- /locale/isctype.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005 Apple Computer, Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | /* 25 | * Tell to generate extern versions of all the top level inline 26 | * functions. 27 | */ 28 | #define _EXTERNALIZE_CTYPE_INLINES_TOP_ 29 | 30 | #include 31 | -------------------------------------------------------------------------------- /nbsdcompat/_nbsd_compat_.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004 Apple Computer, Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | #ifndef __NBSD_COMPAT__H_ 24 | #define __NBSD_COMPAT__H_ 25 | 26 | #define _DIAGASSERT(x) /* */ 27 | #define __warn_references(x,y) /* */ 28 | 29 | #endif /* __NBSD_COMPAT__H_ */ 30 | -------------------------------------------------------------------------------- /tests/nxheap.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #if __has_feature(ptrauth_calls) && !defined(__OPEN_SOURCE) 6 | #include 7 | #endif 8 | 9 | #include 10 | 11 | static char *heap; 12 | static volatile int pass; 13 | static sigjmp_buf jbuf; 14 | 15 | static void __dead2 16 | action(int signo, struct __siginfo *info, void *uap __attribute__((unused))) 17 | { 18 | if (info) { 19 | pass = (signo == SIGBUS && info->si_addr == heap); 20 | } 21 | siglongjmp(jbuf, 0); 22 | } 23 | 24 | T_DECL(nxheap, "Non-executable heap", T_META_CHECK_LEAKS(false), T_META_ASROOT(true)) 25 | { 26 | struct sigaction sa = { 27 | .__sigaction_u.__sa_sigaction = action, 28 | .sa_flags = SA_SIGINFO, 29 | }; 30 | 31 | T_ASSERT_POSIX_ZERO(sigaction(SIGBUS, &sa, NULL), NULL); 32 | 33 | if (sigsetjmp(jbuf, 0)) { 34 | T_PASS("SIGBUS"); 35 | T_END; 36 | } 37 | 38 | T_QUIET; T_ASSERT_NOTNULL((heap = malloc(1)), NULL); 39 | 40 | *heap = (char)0xc3; // retq 41 | #if __has_feature(ptrauth_calls) && !defined(__OPEN_SOURCE) 42 | heap = ptrauth_sign_unauthenticated(heap, ptrauth_key_function_pointer, 0); 43 | #endif 44 | ((void (*)(void))heap)(); // call *%eax 45 | 46 | T_FAIL("SIGBUS"); 47 | } 48 | -------------------------------------------------------------------------------- /include/semaphore.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | #ifndef _BSD_SEMAPHORE_H 24 | #define _BSD_SEMAPHORE_H 25 | 26 | #include 27 | #include 28 | 29 | #include 30 | 31 | #endif /* _BSD_SEMAPHORE_H */ 32 | -------------------------------------------------------------------------------- /libdarwin/init.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Apple Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | #include "internal.h" 24 | 25 | #pragma mark API 26 | void 27 | __os_temporary_resource_shortage(void) 28 | { 29 | (void)sleep(1); 30 | _os_avoid_tail_call(); 31 | } 32 | 33 | void 34 | __libdarwin_init(void) 35 | { 36 | 37 | } 38 | -------------------------------------------------------------------------------- /locale/iswctype.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005 Apple Computer, Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | #include 25 | /* 26 | * Tell to generate extern versions of all the top level inline 27 | * functions. 28 | */ 29 | #define _EXTERNALIZE_WCTYPE_INLINES_TOP_ 30 | 31 | #include 32 | -------------------------------------------------------------------------------- /Platforms/driverkit/Makefile.inc: -------------------------------------------------------------------------------- 1 | # 2 | # Selectable features for DriverKit 3 | # 4 | 5 | # Legacy *64 APIs 6 | #FEATURE_LEGACY_64_APIS = 1 7 | 8 | # Legacy crt1.o environ support 9 | #FEATURE_LEGACY_CRT1_ENVIRON = 1 10 | 11 | # Legacy rune APIs 12 | #FEATURE_LEGACY_RUNE_APIS = 1 13 | 14 | # Legacy utmp APIs 15 | #FEATURE_LEGACY_UTMP_APIS = 1 16 | 17 | # OSThermalNotification APIs 18 | #FEATURE_THERM_NOTIFICATION_APIS = 1 19 | 20 | # No pre-1050 variants (should match sys/cdefs.h) 21 | FEATURE_ONLY_1050_VARIANTS = 1 22 | 23 | # No legacy variants (should match sys/cdefs.h) 24 | FEATURE_ONLY_UNIX_CONFORMANCE = 1 25 | 26 | # Only 64-bit ino_t (should match sys/cdefs.h) 27 | FEATURE_ONLY_64_BIT_INO_T = 1 28 | 29 | # Patch 3333969 30 | #FEATURE_PATCH_3333969 = 1 31 | 32 | # Patch 3417676 33 | #FEATURE_PATCH_3417676 = 1 34 | 35 | # plockstat dtrace support 36 | #FEATURE_PLOCKSTAT = 1 37 | 38 | # Timezone change notification 39 | #FEATURE_TIMEZONE_CHANGE_NOTIFICATION = 1 40 | 41 | # Extensible printf performance enhancement (uses more memory) 42 | #FEATURE_XPRINTF_PERF = 1 43 | 44 | # Disable registration of specific signals () 45 | # FEATURE_SIGNAL_RESTRICTION = 0 46 | 47 | # Enable 32-bit compilation in unistd.h () 48 | # FEATURE_POSIX_ILP32_ALLOW = 0 49 | -------------------------------------------------------------------------------- /gen/dirfd.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 Apple Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | int dirfd(DIR *dirp) { 29 | if (dirp == NULL || dirp->__dd_fd < 0) { 30 | errno = EINVAL; 31 | return -1; 32 | } 33 | 34 | return dirp->__dd_fd; 35 | } 36 | -------------------------------------------------------------------------------- /string/memset_pattern.3: -------------------------------------------------------------------------------- 1 | .Dd October 14, 2005 2 | .Dt MEMSET_PATTERN 3 3 | .Os Darwin 4 | .Sh NAME 5 | .Nm memset_pattern4 , 6 | .Nm memset_pattern8 , 7 | .Nm memset_pattern16 8 | .Nd memset of a multi-byte pattern 9 | .Sh LIBRARY 10 | .Lb libc 11 | .Sh SYNOPSIS 12 | .In string.h 13 | .Ft void 14 | .Fn memset_pattern4 "void *b" "const void *pattern4" "size_t len" 15 | .Ft void 16 | .Fn memset_pattern8 "void *b" "const void *pattern8" "size_t len" 17 | .Ft void 18 | .Fn memset_pattern16 "void *b" "const void *pattern16" "size_t len" 19 | .Sh DESCRIPTION 20 | These are analogous to 21 | .Fn memset , 22 | except that they 23 | fill memory with a replicated pattern either 4, 8, or 16 bytes long. 24 | .Fa b 25 | points to a buffer of size 26 | .Fa len 27 | bytes which is to be filled. The second parameter points to the pattern. 28 | If the buffer length is not an even multiple 29 | of the pattern length, the last instance of the pattern will be truncated. 30 | Neither the buffer nor the pattern pointer need be aligned. 31 | .Sh EXAMPLES 32 | The following example: 33 | .Bd -literal -offset indent 34 | char buf[10]; 35 | 36 | memset_pattern4( buf, "1234", sizeof(buf) ); 37 | .Ed 38 | .Pp 39 | will set the buffer to the value "1234123412". 40 | .Sh SEE ALSO 41 | .Xr memset 3 42 | .Sh HISTORY 43 | These functions first appeared in Mac OS 10.5. -------------------------------------------------------------------------------- /Platforms/macosx/Makefile.inc: -------------------------------------------------------------------------------- 1 | # 2 | # Selectable features for MacOSX 3 | # 4 | 5 | # Legacy *64 APIs 6 | FEATURE_LEGACY_64_APIS = 1 7 | 8 | # Legacy crt1.o environ support 9 | FEATURE_LEGACY_CRT1_ENVIRON = 1 10 | 11 | # Legacy rune APIs 12 | FEATURE_LEGACY_RUNE_APIS = 1 13 | 14 | # Legacy utmp APIs 15 | FEATURE_LEGACY_UTMP_APIS = 1 16 | 17 | # OSThermalNotification APIs 18 | FEATURE_THERM_NOTIFICATION_APIS = 1 19 | 20 | # No pre-1050 variants (should match sys/cdefs.h) 21 | #FEATURE_ONLY_1050_VARIANTS = 1 22 | 23 | # No legacy variants (should match sys/cdefs.h) 24 | .if CURRENT_ARCH 64$ 25 | FEATURE_ONLY_UNIX_CONFORMANCE = 1 26 | .endif 27 | 28 | # Only 64-bit ino_t (should match sys/cdefs.h) 29 | #FEATURE_ONLY_64_BIT_INO_T = 1 30 | 31 | # Patch 3333969 32 | FEATURE_PATCH_3333969 = 1 33 | 34 | # Patch 3417676 35 | FEATURE_PATCH_3417676 = 1 36 | 37 | # plockstat dtrace support 38 | FEATURE_PLOCKSTAT = 1 39 | 40 | # Timezone change notification 41 | FEATURE_TIMEZONE_CHANGE_NOTIFICATION = 1 42 | 43 | # Extensible printf performance enhancement (uses more memory) 44 | FEATURE_XPRINTF_PERF = 1 45 | 46 | # Disable registration of specific signals () 47 | # FEATURE_SIGNAL_RESTRICTION = 0 48 | 49 | # Enable 32-bit compilation in unistd.h () 50 | # FEATURE_POSIX_ILP32_ALLOW = 0 51 | -------------------------------------------------------------------------------- /stdtime/timezone_unix03.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004 Apple Computer, Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | #include 25 | 26 | long timezone = 0; 27 | 28 | __private_extern__ long 29 | _st_get_timezone(void) 30 | { 31 | return timezone; 32 | } 33 | 34 | __private_extern__ void 35 | _st_set_timezone(long tz) 36 | { 37 | timezone = tz; 38 | } 39 | -------------------------------------------------------------------------------- /sys/OSMemoryNotification.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2006 Apple Computer, Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | // Legacy symbols preserved for binary compatibility. 25 | 26 | const char *kOSMemoryNotificationName = "com.apple.system.memorystatus"; 27 | 28 | int OSMemoryNotificationCurrentLevel(void) 29 | { 30 | return 0; // OSMemoryNotificationLevelNormal 31 | } 32 | -------------------------------------------------------------------------------- /include/termios.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | #ifndef __TERMIOS_H__ 24 | #define __TERMIOS_H__ 25 | 26 | #include 27 | #include 28 | #include <_types.h> 29 | #include 30 | 31 | __BEGIN_DECLS 32 | pid_t tcgetsid(int); 33 | __END_DECLS 34 | 35 | #endif /* __TERMIOS_H__ */ 36 | -------------------------------------------------------------------------------- /string/FreeBSD/timingsafe_bcmp.c: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: timingsafe_bcmp.c,v 1.3 2015/08/31 02:53:57 guenther Exp $ */ 2 | /* 3 | * Copyright (c) 2010 Damien Miller. All rights reserved. 4 | * 5 | * Permission to use, copy, modify, and distribute this software for any 6 | * purpose with or without fee is hereby granted, provided that the above 7 | * copyright notice and this permission notice appear in all copies. 8 | * 9 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16 | */ 17 | 18 | #include 19 | __FBSDID("$FreeBSD$"); 20 | 21 | #include 22 | 23 | int 24 | timingsafe_bcmp(const void *b1, const void *b2, size_t n) 25 | { 26 | const unsigned char *p1 = b1, *p2 = b2; 27 | unsigned char ret = 0; 28 | 29 | for (; n > 0; n--) { 30 | ret |= *p1++ ^ *p2++; 31 | } 32 | 33 | /* map zero to zero and nonzero to one */ 34 | return (ret + 0xff) >> 8; 35 | } 36 | -------------------------------------------------------------------------------- /uuid/namespace.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004 Apple Computer, Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | #ifndef _UUID_NAMESPACES_H_ 25 | #define _UUID_NAMESPACES_H_ 26 | 27 | #include 28 | 29 | UUID_DEFINE( kFSUUIDNamespaceSHA1, 0xB3, 0xE2, 0x0F, 0x39, 0xF2, 0x92, 0x11, 0xD6, 0x97, 0xA4, 0x00, 0x30, 0x65, 0x43, 0xEC, 0xAC ); 30 | 31 | #endif /* _UUID_NAMESPACES_H_ */ 32 | -------------------------------------------------------------------------------- /man/gethostuuid.2: -------------------------------------------------------------------------------- 1 | .Dd Nov 5, 2008 2 | .Dt GETHOSTUUID \&2 "Mac OS X System Calls Manual" 3 | .Os "Mac OS X" 4 | .Sh NAME 5 | .Nm gethostuuid 6 | .Nd return a unique identifier for the current machine 7 | .Sh SYNOPSIS 8 | .In unistd.h 9 | .Ft int 10 | .Fo gethostuuid 11 | .Fa "uuid_t id" 12 | .Fa "const struct timespec *wait" 13 | .Fc 14 | .Sh DESCRIPTION 15 | The 16 | .Fn gethostuuid 17 | function returns a 16-byte 18 | .Ft uuid_t 19 | specified by 20 | .Fa id , 21 | that uniquely identifies the current machine. 22 | Be aware that the hardware identifiers that 23 | .Fn gethostuuid 24 | uses to generate the UUID can themselves be modified. 25 | .Pp 26 | The 27 | .Fa wait 28 | argument is a pointer to a 29 | .Ft "struct timespec" 30 | that specifies the maximum time to wait for the result. 31 | Setting the 32 | .Fa tv_sec 33 | and 34 | .Fa tv_nsec 35 | fields to zero means to wait indefinitely until it completes. 36 | .Sh RETURN VALUES 37 | The 38 | .Fn gethostuuid 39 | function returns zero on success or -1 on error. 40 | .Sh ERRORS 41 | The 42 | .Fn gethostuuid 43 | functions fails if: 44 | .Bl -tag -width Er 45 | .It Bq Er EFAULT 46 | .Fa wait 47 | points to memory that is not a valid part of the process 48 | address space. 49 | .It Bq Er EWOULDBLOCK 50 | The 51 | .Fa wait 52 | timeout expired before the UUID could be obtained. 53 | .El 54 | .Sh SEE ALSO 55 | .Xr uuid 3 56 | -------------------------------------------------------------------------------- /secure/memset_chk.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007-2013 Apple Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | #include 25 | #include 26 | #include "secure.h" 27 | 28 | void * 29 | __memset_chk (void *dest, int val, size_t len, size_t dstlen) 30 | { 31 | if (__builtin_expect (dstlen < len, 0)) 32 | __chk_fail_overflow (); 33 | 34 | return memset (dest, val, len); 35 | } 36 | -------------------------------------------------------------------------------- /include/aio.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2003 Apple Computer, Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | /* 24 | * File: aio.h 25 | * Author: Umesh Vaishampayan [umeshv@apple.com] 26 | * 05-Feb-2003 umeshv Created. 27 | * 28 | * Header file for POSIX Asynchronous IO APIs 29 | * 30 | */ 31 | 32 | #ifndef _AIO_H_ 33 | #define _AIO_H_ 34 | 35 | #include 36 | 37 | #endif /* _AIO_H_ */ 38 | -------------------------------------------------------------------------------- /secure/memmove_chk.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007-2013 Apple Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | #include 25 | #include 26 | #include "secure.h" 27 | 28 | void * 29 | __memmove_chk (void *dest, const void *src, size_t len, size_t dstlen) 30 | { 31 | if (__builtin_expect (dstlen < len, 0)) 32 | __chk_fail_overflow (); 33 | 34 | return memmove (dest, src, len); 35 | } 36 | -------------------------------------------------------------------------------- /include/xlocale/_langinfo.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005 Apple Computer, Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | #ifndef _XLOCALE__LANGINFO_H_ 25 | #define _XLOCALE__LANGINFO_H_ 26 | 27 | #include 28 | #include <_types/_nl_item.h> 29 | #include <_xlocale.h> 30 | 31 | __BEGIN_DECLS 32 | char *nl_langinfo_l(nl_item, locale_t); 33 | __END_DECLS 34 | 35 | #endif /* _XLOCALE__LANGINFO_H_ */ 36 | -------------------------------------------------------------------------------- /include/standards.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1999, 2010 Apple Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | /* 24 | * Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved 25 | */ 26 | 27 | #ifndef _STANDARDS_H 28 | #define _STANDARDS_H 29 | 30 | #include 31 | 32 | #warning "The use of is deprecated, and it will be removed in a future release." 33 | 34 | #endif /* _STANDARDS_H */ 35 | -------------------------------------------------------------------------------- /tests/open_memstream.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | #include 6 | 7 | static void 8 | perf_fixed_size(size_t size_per_write) 9 | { 10 | dt_stat_time_t latency = dt_stat_time_create("write_latency", 11 | "adding %zu bytes to a memstream", size_per_write); 12 | dt_stat_set_variable_d(latency, "bytes", (double)size_per_write); 13 | char *src = calloc(1, size_per_write); 14 | T_QUIET; T_ASSERT_NOTNULL(src, "allocated source buffer"); 15 | 16 | while (!dt_stat_stable(latency)) { 17 | char *buf = NULL; 18 | size_t size = 0; 19 | 20 | FILE *victim = open_memstream(&buf, &size); 21 | T_QUIET; T_WITH_ERRNO; T_ASSERT_NOTNULL(victim, "opened memstream"); 22 | 23 | T_STAT_MEASURE_BATCH(latency) { 24 | (void)fwrite(src, size_per_write, 1, victim); 25 | } 26 | 27 | fclose(victim); 28 | T_QUIET; T_ASSERT_NOTNULL(buf, "buffer was set by open_memstream"); 29 | T_QUIET; T_ASSERT_GE(size, size_per_write, 30 | "memstream added non-zero bytes"); 31 | 32 | free(buf); 33 | } 34 | 35 | free(src); 36 | dt_stat_finalize(latency); 37 | } 38 | 39 | T_DECL(perf_open_memstream, "measure the performance of open_memstream") 40 | { 41 | size_t sizes[] = { 1, 8, 16, 64, 1024, 2048, 4096, 16 * 1024 }; 42 | for (size_t i = 0; i < sizeof(sizes) / sizeof(sizes[0]); i++) { 43 | perf_fixed_size(sizes[i]); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /include/_xlocale.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005 Apple Computer, Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | #ifndef __XLOCALE_H_ 25 | #define __XLOCALE_H_ 26 | 27 | #include 28 | 29 | struct _xlocale; /* forward reference */ 30 | typedef struct _xlocale * locale_t; 31 | 32 | __BEGIN_DECLS 33 | int ___mb_cur_max(void); 34 | int ___mb_cur_max_l(locale_t); 35 | __END_DECLS 36 | 37 | #endif /* __XLOCALE_H_ */ 38 | -------------------------------------------------------------------------------- /libdarwin/h/libdarwin_init.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 Apple Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | /*! 25 | * @header 26 | * libdarwin initialization header. 27 | */ 28 | #ifndef __DARWIN_INIT_H 29 | #define __DARWIN_INIT_H 30 | 31 | #include 32 | #include 33 | 34 | __BEGIN_DECLS; 35 | 36 | OS_EXPORT 37 | void 38 | __libdarwin_init(void); 39 | 40 | __END_DECLS; 41 | 42 | #endif // __DARWIN_INIT_H 43 | -------------------------------------------------------------------------------- /tests/timingsafe_bcmp.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | 6 | T_DECL(timingsafe_bcmp, "tests for timingsafe_bcmp(3)") 7 | { 8 | // empty 9 | T_ASSERT_EQ(0, timingsafe_bcmp(NULL, NULL, 0), NULL); 10 | T_ASSERT_EQ(0, timingsafe_bcmp("foo", "foo", 0), NULL); 11 | T_ASSERT_EQ(0, timingsafe_bcmp("foo", "bar", 0), NULL); 12 | 13 | // equal 14 | T_ASSERT_EQ(0, timingsafe_bcmp("foo", "foo", strlen("foo")), NULL); 15 | 16 | // unequal 17 | T_ASSERT_EQ(1, timingsafe_bcmp("foo", "bar", strlen("foo")), NULL); 18 | T_ASSERT_EQ(1, timingsafe_bcmp("foo", "goo", strlen("foo")), NULL); 19 | T_ASSERT_EQ(1, timingsafe_bcmp("foo", "fpo", strlen("foo")), NULL); 20 | T_ASSERT_EQ(1, timingsafe_bcmp("foo", "fop", strlen("foo")), NULL); 21 | 22 | // all possible bitwise differences 23 | int i; 24 | for (i = 1; i < 256; i += 1) { 25 | unsigned char a = 0; 26 | unsigned char b = (unsigned char)i; 27 | 28 | T_ASSERT_EQ(1, timingsafe_bcmp(&a, &b, sizeof(a)), NULL); 29 | } 30 | 31 | // large 32 | char buf[1024 * 16]; 33 | arc4random_buf(buf, sizeof(buf)); 34 | T_ASSERT_EQ(0, timingsafe_bcmp(buf, buf, sizeof(buf)), NULL); 35 | T_ASSERT_EQ(1, timingsafe_bcmp(buf, buf + 1, sizeof(buf) - 1), NULL); 36 | T_ASSERT_EQ(1, timingsafe_bcmp(buf, buf + 128, 128), NULL); 37 | 38 | memcpy(buf+128, buf, 128); 39 | T_ASSERT_EQ(0, timingsafe_bcmp(buf, buf + 128, 128), NULL); 40 | } 41 | -------------------------------------------------------------------------------- /locale/runedepreciated.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004 Apple Computer, Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | #undef sgetrune 25 | #undef sputrune 26 | #undef __sgetrune 27 | #undef __sputrune 28 | 29 | extern const char __rune_depreciated_msg[]; 30 | 31 | /* The real, depreciated routines, that don't print the depreciated message */ 32 | extern rune_t __sgetrune(const char *, size_t, char const **); 33 | extern int __sputrune(rune_t, char *, size_t, char **); 34 | -------------------------------------------------------------------------------- /tests/regex/datafiles/forcedassoc.dat: -------------------------------------------------------------------------------- 1 | NOTE left-assoc:pass-all right-assoc:pass-all : 2002-04-29 2 | 3 | E (a|ab)(c|bcd) abcd (0,4)(0,1)(1,4) 4 | E (a|ab)(bcd|c) abcd (0,4)(0,1)(1,4) 5 | E (ab|a)(c|bcd) abcd (0,4)(0,1)(1,4) 6 | E (ab|a)(bcd|c) abcd (0,4)(0,1)(1,4) 7 | E ((a|ab)(c|bcd))(d*) abcd (0,4)(0,4)(0,1)(1,4)(4,4) 8 | E ((a|ab)(bcd|c))(d*) abcd (0,4)(0,4)(0,1)(1,4)(4,4) 9 | E ((ab|a)(c|bcd))(d*) abcd (0,4)(0,4)(0,1)(1,4)(4,4) 10 | E ((ab|a)(bcd|c))(d*) abcd (0,4)(0,4)(0,1)(1,4)(4,4) 11 | E (a|ab)((c|bcd)(d*)) abcd (0,4)(0,2)(2,4)(2,3)(3,4) 12 | E (a|ab)((bcd|c)(d*)) abcd (0,4)(0,2)(2,4)(2,3)(3,4) 13 | E (ab|a)((c|bcd)(d*)) abcd (0,4)(0,2)(2,4)(2,3)(3,4) 14 | E (ab|a)((bcd|c)(d*)) abcd (0,4)(0,2)(2,4)(2,3)(3,4) 15 | E (a*)(b|abc) abc (0,3)(0,0)(0,3) 16 | E (a*)(abc|b) abc (0,3)(0,0)(0,3) 17 | E ((a*)(b|abc))(c*) abc (0,3)(0,3)(0,0)(0,3)(3,3) 18 | E ((a*)(abc|b))(c*) abc (0,3)(0,3)(0,0)(0,3)(3,3) 19 | E (a*)((b|abc)(c*)) abc (0,3)(0,1)(1,3)(1,2)(2,3) 20 | E (a*)((abc|b)(c*)) abc (0,3)(0,1)(1,3)(1,2)(2,3) 21 | E (a*)(b|abc) abc (0,3)(0,0)(0,3) 22 | E (a*)(abc|b) abc (0,3)(0,0)(0,3) 23 | E ((a*)(b|abc))(c*) abc (0,3)(0,3)(0,0)(0,3)(3,3) 24 | E ((a*)(abc|b))(c*) abc (0,3)(0,3)(0,0)(0,3)(3,3) 25 | E (a*)((b|abc)(c*)) abc (0,3)(0,1)(1,3)(1,2)(2,3) 26 | E (a*)((abc|b)(c*)) abc (0,3)(0,1)(1,3)(1,2)(2,3) 27 | E (a|ab) ab (0,2)(0,2) 28 | E (ab|a) ab (0,2)(0,2) 29 | E (a|ab)(b*) ab (0,2)(0,2)(2,2) 30 | E (ab|a)(b*) ab (0,2)(0,2)(2,2) 31 | -------------------------------------------------------------------------------- /emulated/tcgetsid.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2003 Apple Computer, Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | /* 25 | * tcgetsid.c 26 | */ 27 | #include 28 | #include 29 | #include /* ordering avoid termios.h redeclarations */ 30 | 31 | pid_t 32 | tcgetsid(int fildes) 33 | { 34 | pid_t sid; 35 | 36 | if (ioctl(fildes, TIOCGSID, (char *)&sid) < 0) 37 | return ((pid_t)-1); 38 | 39 | return (sid); 40 | } 41 | 42 | /* EOF */ 43 | -------------------------------------------------------------------------------- /uuid/uuid-config.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004 Apple Computer, Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | // MacOS-specific settings for uuid 25 | #define HAVE_NETINET_IN_H 26 | #define HAVE_NET_IF_DL_H 27 | #define HAVE_NET_IF_H 28 | #define HAVE_SA_LEN 29 | #define HAVE_SRANDOM 30 | #define HAVE_STDINT_H 31 | #define HAVE_STDLIB_H 32 | #define HAVE_SYS_IOCTL_H 33 | #define HAVE_SYS_SOCKET_H 34 | #define HAVE_SYS_SOCKIO_H 35 | #define HAVE_UNISTD_H 36 | #define UUID_UNPARSE_DEFAULT_UPPER 37 | -------------------------------------------------------------------------------- /stdlib/FreeBSD/tfind.c: -------------------------------------------------------------------------------- 1 | /* $NetBSD: tfind.c,v 1.2 1999/09/16 11:45:37 lukem Exp $ */ 2 | 3 | /* 4 | * Tree search generalized from Knuth (6.2.2) Algorithm T just like 5 | * the AT&T man page says. 6 | * 7 | * The node_t structure is for internal use only, lint doesn't grok it. 8 | * 9 | * Written by reading the System V Interface Definition, not the code. 10 | * 11 | * Totally public domain. 12 | */ 13 | 14 | #include 15 | #if 0 16 | #if defined(LIBC_SCCS) && !defined(lint) 17 | __RCSID("$NetBSD: tfind.c,v 1.2 1999/09/16 11:45:37 lukem Exp $"); 18 | #endif /* LIBC_SCCS and not lint */ 19 | #endif 20 | __FBSDID("$FreeBSD: src/lib/libc/stdlib/tfind.c,v 1.5 2003/01/05 02:43:18 tjr Exp $"); 21 | 22 | #define _SEARCH_PRIVATE 23 | #include 24 | #include 25 | 26 | /* find a node, or return 0 */ 27 | void * 28 | tfind(vkey, vrootp, compar) 29 | const void *vkey; /* key to be found */ 30 | void * const *vrootp; /* address of the tree root */ 31 | int (*compar)(const void *, const void *); 32 | { 33 | node_t **rootp = (node_t **)vrootp; 34 | 35 | if (rootp == NULL) 36 | return NULL; 37 | 38 | while (*rootp != NULL) { /* T1: */ 39 | int r; 40 | 41 | if ((r = (*compar)(vkey, (*rootp)->key)) == 0) /* T2: */ 42 | return *rootp; /* key found */ 43 | rootp = (r < 0) ? 44 | &(*rootp)->llink : /* T3: follow left branch */ 45 | &(*rootp)->rlink; /* T4: follow right branch */ 46 | } 47 | return NULL; 48 | } 49 | -------------------------------------------------------------------------------- /gen/get_compat.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004 Apple Computer, Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | #include 25 | 26 | extern bool compat_mode(const char *function, const char *mode); 27 | 28 | /* this will eventually cache the result, you need to call it with a 29 | static string otherwise it will cache the wrong result. It ought 30 | to be fast enough to use in things like malloc(2) without extra 31 | tricks */ 32 | #define COMPAT_MODE(func, mode) compat_mode(func, mode) 33 | -------------------------------------------------------------------------------- /compat-43/sigaltstk.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, 2006 Apple Computer, Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | #include 24 | #include 25 | 26 | int __sigaltstack(const stack_t * __restrict, stack_t * __restrict); 27 | 28 | /* UNIX03 only */ 29 | int sigaltstack(const stack_t * __restrict nstack, stack_t * __restrict ostack) 30 | { 31 | if (nstack && nstack->ss_size < MINSIGSTKSZ) { 32 | errno = ENOMEM; 33 | return -1; 34 | } 35 | return __sigaltstack(nstack, ostack); 36 | } 37 | -------------------------------------------------------------------------------- /include/authentication.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | #ifndef __AUTHENTICATION_H__ 25 | #define __AUTHENTICATION_H__ 26 | 27 | #include 28 | 29 | __BEGIN_DECLS 30 | extern char *groupNameForTask(int taskNum); 31 | extern int isAuthenticatedAsAdministrator(void); 32 | extern int isAuthenticatedAsAdministratorForTask(int taskNum); 33 | extern int isAuthenticatedAsRoot(void); 34 | __END_DECLS 35 | 36 | #endif /* __AUTHENTICATION_H__ */ 37 | -------------------------------------------------------------------------------- /gen/raise.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Apple, Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | int raise(int sig) { 30 | int error = pthread_kill(pthread_self(), sig); 31 | switch (error) { 32 | case 0: 33 | return 0; 34 | case ENOTSUP: 35 | return kill(getpid(), sig); 36 | default: 37 | errno = error; 38 | return -1; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /gen/thread_stack_pcs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 Apple Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * "Portions Copyright (c) 2004 Apple Computer, Inc. All Rights 7 | * Reserved. This file contains Original Code and/or Modifications of 8 | * Original Code as defined in and that are subject to the Apple Public 9 | * Source License Version 1.0 (the 'License'). You may not use this file 10 | * except in compliance with the License. Please obtain a copy of the 11 | * License at http://www.apple.com/publicsource and read it before using 12 | * this file. 13 | * 14 | * The Original Code and all software distributed under the License are 15 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 16 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 17 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the 19 | * License for the specific language governing rights and limitations 20 | * under the License." 21 | * 22 | * @APPLE_LICENSE_HEADER_END@ 23 | */ 24 | 25 | #ifndef _LIBC_THREAD_STACK_PCS_H 26 | #define _LIBC_THREAD_STACK_PCS_H 27 | 28 | #include 29 | #include 30 | #include 31 | 32 | __BEGIN_DECLS 33 | 34 | extern void thread_stack_pcs(vm_address_t *buffer, unsigned max, unsigned *num); 35 | 36 | __END_DECLS 37 | 38 | #endif // _LIBC_THREAD_STACK_PCS_H 39 | -------------------------------------------------------------------------------- /include/xlocale/_monetary.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, 2009 Apple Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | #ifndef _XLOCALE__MONETARY_H_ 25 | #define _XLOCALE__MONETARY_H_ 26 | 27 | #include 28 | #include <_types.h> 29 | #include 30 | #include 31 | #include <_xlocale.h> 32 | 33 | __BEGIN_DECLS 34 | ssize_t strfmon_l(char *, size_t, locale_t, const char *, ...) 35 | __strfmonlike(4, 5); 36 | __END_DECLS 37 | 38 | #endif /* _XLOCALE__MONETARY_H_ */ 39 | -------------------------------------------------------------------------------- /stdlib/FreeBSD/insque.3: -------------------------------------------------------------------------------- 1 | .\" 2 | .\" Initial implementation: 3 | .\" Copyright (c) 2002 Robert Drehmel 4 | .\" All rights reserved. 5 | .\" 6 | .\" As long as the above copyright statement and this notice remain 7 | .\" unchanged, you can do what ever you want with this file. 8 | .\" 9 | .\" $FreeBSD: src/lib/libc/stdlib/insque.3,v 1.3 2003/02/25 21:59:36 robert Exp $ 10 | .\" 11 | .Dd October 10, 2002 12 | .Dt INSQUE 3 13 | .Os 14 | .Sh NAME 15 | .Nm insque , 16 | .Nm remque 17 | .Nd doubly-linked list management 18 | .Sh LIBRARY 19 | .Lb libc 20 | .Sh SYNOPSIS 21 | .In search.h 22 | .Ft void 23 | .Fn insque "void *element" "void *pred" 24 | .Ft void 25 | .Fn remque "void *element" 26 | .Sh DESCRIPTION 27 | The 28 | .Fn insque 29 | and 30 | .Fn remque 31 | functions encapsulate the ever-repeating task of doing insertion and 32 | removal operations on doubly linked lists. 33 | The functions expect their 34 | arguments to point to a structure whose first and second members are 35 | pointers to the next and previous element, respectively. 36 | The 37 | .Fn insque 38 | function also allows the 39 | .Fa pred 40 | argument to be a 41 | .Dv NULL 42 | pointer for the initialization of a new list's 43 | head element. 44 | .Sh STANDARDS 45 | The 46 | .Fn insque 47 | and 48 | .Fn remque 49 | functions conform to 50 | .St -p1003.1-2001 . 51 | .Sh HISTORY 52 | The 53 | .Fn insque 54 | and 55 | .Fn remque 56 | functions appeared in 57 | .Bx 4.2 . 58 | In 59 | .Fx 5.0 , 60 | they reappeared conforming to 61 | .St -p1003.1-2001 . 62 | -------------------------------------------------------------------------------- /secure/vsnprintf_chk.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007-2013 Apple Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include "secure.h" 29 | 30 | int 31 | __vsnprintf_chk (char *dest, size_t len, int flags, size_t dstlen, 32 | const char *format, va_list arg) 33 | { 34 | int done; 35 | 36 | if (__builtin_expect (dstlen < len, 0)) 37 | __chk_fail_overflow (); 38 | 39 | done = vsnprintf (dest, len, format, arg); 40 | 41 | return done; 42 | } 43 | -------------------------------------------------------------------------------- /string/stpcpy.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 Apple, Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | #include 25 | 26 | char * 27 | stpcpy(char * restrict dst, const char * restrict src) { 28 | const size_t length = strlen(src); 29 | // The stpcpy() and strcpy() functions copy the string src to dst 30 | // (including the terminating '\0' character). 31 | memcpy(dst, src, length + 1); 32 | // The stpcpy() and stpncpy() functions return a pointer to the 33 | // terminating '\0' character of dst. 34 | return dst + length; 35 | } 36 | -------------------------------------------------------------------------------- /include/_types/_uint8_t.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 Apple Inc. All rights reserved. 3 | * 4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. The rights granted to you under the License 10 | * may not be used to create, or enable the creation or redistribution of, 11 | * unlawful or unlicensed copies of an Apple operating system, or to 12 | * circumvent, violate, or enable the circumvention or violation of, any 13 | * terms of an Apple operating system software license agreement. 14 | * 15 | * Please obtain a copy of the License at 16 | * http://www.opensource.apple.com/apsl/ and read it before using this file. 17 | * 18 | * The Original Code and all software distributed under the License are 19 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 23 | * Please see the License for the specific language governing rights and 24 | * limitations under the License. 25 | * 26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ 27 | */ 28 | 29 | #ifndef _UINT8_T 30 | #define _UINT8_T 31 | typedef unsigned char uint8_t; 32 | #endif /* _UINT8_T */ 33 | -------------------------------------------------------------------------------- /regex/TRE/tre-config.h: -------------------------------------------------------------------------------- 1 | /* lib/tre-config.h. Generated from tre-config.h.in by configure. */ 2 | /* tre-config.h.in. This file has all definitions that are needed in 3 | `tre.h'. Note that this file must contain only the bare minimum 4 | of definitions without the TRE_ prefix to avoid conflicts between 5 | definitions here and definitions included from somewhere else. */ 6 | 7 | /* Define to 1 if you have the header file. */ 8 | /* #undef HAVE_LIBUTF8_H */ 9 | 10 | /* Define to 1 if the system has the type `reg_errcode_t'. */ 11 | /* #undef HAVE_REG_ERRCODE_T */ 12 | 13 | /* Define to 1 if you have the header file. */ 14 | #define HAVE_SYS_TYPES_H 1 15 | 16 | /* Define to 1 if you have the header file. */ 17 | #define HAVE_WCHAR_H 1 18 | 19 | /* Define if you want to enable approximate matching functionality. */ 20 | /* #undef TRE_APPROX */ 21 | 22 | /* Define to enable multibyte character set support. */ 23 | #define TRE_MULTIBYTE 1 24 | 25 | /* Define to the absolute path to the system tre.h */ 26 | #define TRE_SYSTEM_REGEX_H_PATH 27 | 28 | /* Define to include the system regex.h from tre.h */ 29 | #define TRE_USE_SYSTEM_REGEX_H 1 30 | 31 | /* Define to enable wide character (wchar_t) support. */ 32 | #define TRE_WCHAR 1 33 | 34 | /* TRE version string. */ 35 | #define TRE_VERSION "0.8.0" 36 | 37 | /* TRE version level 1. */ 38 | #define TRE_VERSION_1 0 39 | 40 | /* TRE version level 2. */ 41 | #define TRE_VERSION_2 8 42 | 43 | /* TRE version level 3. */ 44 | #define TRE_VERSION_3 0 45 | -------------------------------------------------------------------------------- /include/_types/_uint32_t.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 Apple Inc. All rights reserved. 3 | * 4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. The rights granted to you under the License 10 | * may not be used to create, or enable the creation or redistribution of, 11 | * unlawful or unlicensed copies of an Apple operating system, or to 12 | * circumvent, violate, or enable the circumvention or violation of, any 13 | * terms of an Apple operating system software license agreement. 14 | * 15 | * Please obtain a copy of the License at 16 | * http://www.opensource.apple.com/apsl/ and read it before using this file. 17 | * 18 | * The Original Code and all software distributed under the License are 19 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 23 | * Please see the License for the specific language governing rights and 24 | * limitations under the License. 25 | * 26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ 27 | */ 28 | 29 | #ifndef _UINT32_T 30 | #define _UINT32_T 31 | typedef unsigned int uint32_t; 32 | #endif /* _UINT32_T */ 33 | -------------------------------------------------------------------------------- /secure/strlcpy_chk.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2013 Apple Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | #include 25 | #include 26 | #include "secure.h" 27 | 28 | size_t 29 | __strlcpy_chk (char *restrict dest, char *restrict src, 30 | size_t len, size_t dstlen) 31 | { 32 | size_t retval; 33 | if (__builtin_expect (dstlen < len, 0)) 34 | __chk_fail_overflow (); 35 | 36 | retval = strlcpy (dest, src, len); 37 | 38 | if (retval < len) 39 | len = retval + 1; 40 | 41 | __chk_overlap(dest, len, src, len); 42 | 43 | return retval; 44 | } 45 | -------------------------------------------------------------------------------- /include/_types/_uint16_t.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 Apple Inc. All rights reserved. 3 | * 4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. The rights granted to you under the License 10 | * may not be used to create, or enable the creation or redistribution of, 11 | * unlawful or unlicensed copies of an Apple operating system, or to 12 | * circumvent, violate, or enable the circumvention or violation of, any 13 | * terms of an Apple operating system software license agreement. 14 | * 15 | * Please obtain a copy of the License at 16 | * http://www.opensource.apple.com/apsl/ and read it before using this file. 17 | * 18 | * The Original Code and all software distributed under the License are 19 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 23 | * Please see the License for the specific language governing rights and 24 | * limitations under the License. 25 | * 26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ 27 | */ 28 | 29 | #ifndef _UINT16_T 30 | #define _UINT16_T 31 | typedef unsigned short uint16_t; 32 | #endif /* _UINT16_T */ 33 | -------------------------------------------------------------------------------- /include/_types/_uint64_t.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 Apple Inc. All rights reserved. 3 | * 4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. The rights granted to you under the License 10 | * may not be used to create, or enable the creation or redistribution of, 11 | * unlawful or unlicensed copies of an Apple operating system, or to 12 | * circumvent, violate, or enable the circumvention or violation of, any 13 | * terms of an Apple operating system software license agreement. 14 | * 15 | * Please obtain a copy of the License at 16 | * http://www.opensource.apple.com/apsl/ and read it before using this file. 17 | * 18 | * The Original Code and all software distributed under the License are 19 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 23 | * Please see the License for the specific language governing rights and 24 | * limitations under the License. 25 | * 26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ 27 | */ 28 | 29 | #ifndef _UINT64_T 30 | #define _UINT64_T 31 | typedef unsigned long long uint64_t; 32 | #endif /* _UINT64_T */ 33 | -------------------------------------------------------------------------------- /emulated/bsd_signal.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2003 Apple Computer, Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | /* 25 | * bsd_signal() function, per POIX 1003.1-2003 26 | */ 27 | #include 28 | 29 | void 30 | (*bsd_signal(int sig, void (*func)(int)))(int) 31 | { 32 | struct sigaction act, oact; 33 | 34 | 35 | act.sa_handler = func; 36 | act.sa_flags = SA_RESTART; 37 | 38 | sigemptyset(&act.sa_mask); 39 | sigaddset(&act.sa_mask, sig); 40 | if (sigaction(sig, &act, &oact) == -1) 41 | return(SIG_ERR); 42 | 43 | return(oact.sa_handler); 44 | } 45 | -------------------------------------------------------------------------------- /secure/strcpy_chk.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007-2013 Apple Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | #include 25 | #include 26 | #include "secure.h" 27 | 28 | char * 29 | __strcpy_chk (char *restrict dest, char *restrict src, size_t dstlen) 30 | { 31 | // stpcpy returns a pointer to the \0 32 | size_t len = stpcpy(dest, src) - dest + 1; 33 | 34 | if (__builtin_expect (dstlen < len, 0)) 35 | __chk_fail_overflow (); 36 | 37 | if (__builtin_expect (__chk_assert_no_overlap != 0, 1)) 38 | __chk_overlap(dest, len, src, len); 39 | 40 | return dest; 41 | } 42 | -------------------------------------------------------------------------------- /secure/stpcpy_chk.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007-2013 Apple Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | #include 25 | #include 26 | #include "secure.h" 27 | 28 | char * 29 | __stpcpy_chk (char *dest, const char *src, size_t dstlen) 30 | { 31 | char *retval = stpcpy(dest, src); // Returns a pointer to the \0 32 | size_t len = retval - dest + 1; 33 | 34 | if (__builtin_expect (dstlen < len, 0)) 35 | __chk_fail_overflow (); 36 | 37 | if (__builtin_expect (__chk_assert_no_overlap != 0, 1)) 38 | __chk_overlap(dest, len, src, len); 39 | 40 | return retval; 41 | } 42 | -------------------------------------------------------------------------------- /include/_types/_nl_item.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 Apple Inc. All rights reserved. 3 | * 4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. The rights granted to you under the License 10 | * may not be used to create, or enable the creation or redistribution of, 11 | * unlawful or unlicensed copies of an Apple operating system, or to 12 | * circumvent, violate, or enable the circumvention or violation of, any 13 | * terms of an Apple operating system software license agreement. 14 | * 15 | * Please obtain a copy of the License at 16 | * http://www.opensource.apple.com/apsl/ and read it before using this file. 17 | * 18 | * The Original Code and all software distributed under the License are 19 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 23 | * Please see the License for the specific language governing rights and 24 | * limitations under the License. 25 | * 26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ 27 | */ 28 | 29 | #ifndef _NL_ITEM 30 | #define _NL_ITEM 31 | #include <_types.h> 32 | typedef __darwin_nl_item nl_item; 33 | #endif /* _NL_ITEM */ -------------------------------------------------------------------------------- /include/_types/_wctype_t.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 Apple Inc. All rights reserved. 3 | * 4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. The rights granted to you under the License 10 | * may not be used to create, or enable the creation or redistribution of, 11 | * unlawful or unlicensed copies of an Apple operating system, or to 12 | * circumvent, violate, or enable the circumvention or violation of, any 13 | * terms of an Apple operating system software license agreement. 14 | * 15 | * Please obtain a copy of the License at 16 | * http://www.opensource.apple.com/apsl/ and read it before using this file. 17 | * 18 | * The Original Code and all software distributed under the License are 19 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 23 | * Please see the License for the specific language governing rights and 24 | * limitations under the License. 25 | * 26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ 27 | */ 28 | 29 | #ifndef _WCTYPE_T 30 | #define _WCTYPE_T 31 | #include <_types.h> 32 | typedef __darwin_wctype_t wctype_t; 33 | #endif /* _WCTYPE_T */ -------------------------------------------------------------------------------- /xcodescripts/build_linklists.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # build_linklists.sh 4 | # Libc 5 | 6 | # Skip script during installhdrs 7 | if [ "$ACTION" == installhdrs ]; then exit 0; fi 8 | # BUILD_ARCHIVES needs to be set in the project settings 9 | if [ -z "$BUILD_ARCHIVES" ]; then exit 0; fi 10 | 11 | [ ! -d "$BUILT_PRODUCTS_DIR" ] && mkdir -p "$BUILT_PRODUCTS_DIR" 12 | [ ! -d "$DERIVED_FILES_DIR" ] && mkdir -p "$DERIVED_FILES_DIR" 13 | 14 | NORMAL_LIST="$BUILT_PRODUCTS_DIR/normal.linklist" 15 | DEBUG_LIST="$BUILT_PRODUCTS_DIR/debug.linklist" 16 | INTERPOSABLE_LIST="$DERIVED_FILES_DIR/interposable.list" 17 | UNEXPORT_LIST="$DERIVED_FILES_DIR/unexport.list" 18 | 19 | rm -f "$NORMAL_LIST" 20 | rm -f "$DEBUG_LIST" 21 | rm -f "$INTERPOSABLE_LIST" 22 | rm -f "$UNEXPORT_LIST" 23 | 24 | for x in ${BUILD_ARCHIVES[@]}; do 25 | nm -AUamgf "$BUILT_PRODUCTS_DIR/lib${x}.a" 2>/dev/null | \ 26 | grep '__TEXT,__text' | \ 27 | grep -vE '\$VARIANT' | \ 28 | awk '{ print $NF }' >> "$INTERPOSABLE_LIST" 29 | 30 | nm -AUamgf "$BUILT_PRODUCTS_DIR/lib${x}.a" 2>/dev/null | \ 31 | awk '/\$VARIANT/ { print $NF }' >> "$UNEXPORT_LIST" 32 | 33 | echo "$BUILT_PRODUCTS_DIR/lib${x}.a" >> "$NORMAL_LIST.libtool" 34 | filename=$(printf %s "$BUILT_PRODUCTS_DIR/lib${x}.a" | sed "s/\ /\\\ /g") 35 | echo "$filename" >> "$NORMAL_LIST" 36 | 37 | echo "$BUILT_PRODUCTS_DIR/lib${x}_debug.a" >> "$DEBUG_LIST.libtool" 38 | filename=$(printf %s "$BUILT_PRODUCTS_DIR/lib${x}_debug.a" | sed "s/\ /\\\ /g") 39 | echo "$filename" >> "$DEBUG_LIST" 40 | done 41 | 42 | touch "$BUILT_PRODUCTS_DIR/deps.c" 43 | 44 | exit 0 45 | -------------------------------------------------------------------------------- /secure/secure.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Apple Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | #ifndef _SECURE_H_ 25 | 26 | #include 27 | 28 | extern void __chk_fail_overflow (void) __attribute__((__noreturn__)); 29 | extern void __chk_fail_overlap (void) __attribute__((__noreturn__)); 30 | 31 | /* Assert if a -> a+an and b -> b+bn overlap. 32 | * 0-lengths don't overlap anything. 33 | */ 34 | extern void __chk_overlap (const void *a, size_t an, const void *b, size_t bn); 35 | 36 | /* Do we avoid the overlap check for older APIs? */ 37 | extern uint32_t __chk_assert_no_overlap; 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /include/_types/_wctrans_t.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 Apple Inc. All rights reserved. 3 | * 4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. The rights granted to you under the License 10 | * may not be used to create, or enable the creation or redistribution of, 11 | * unlawful or unlicensed copies of an Apple operating system, or to 12 | * circumvent, violate, or enable the circumvention or violation of, any 13 | * terms of an Apple operating system software license agreement. 14 | * 15 | * Please obtain a copy of the License at 16 | * http://www.opensource.apple.com/apsl/ and read it before using this file. 17 | * 18 | * The Original Code and all software distributed under the License are 19 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 23 | * Please see the License for the specific language governing rights and 24 | * limitations under the License. 25 | * 26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ 27 | */ 28 | 29 | #ifndef _WCTRANS_T 30 | #define _WCTRANS_T 31 | #include <_types.h> 32 | typedef __darwin_wctrans_t wctrans_t; 33 | #endif /* _WCTRANS_T */ -------------------------------------------------------------------------------- /emulated/lchmod.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, 2014 Apple Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | // NOTE: This system call emulation should move to libsystem_kernel.dylib 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | int 33 | lchmod(const char *path, mode_t mode) 34 | { 35 | struct attrlist a; 36 | int m; 37 | 38 | bzero(&a, sizeof(a)); 39 | a.bitmapcount = ATTR_BIT_MAP_COUNT; 40 | a.commonattr = ATTR_CMN_ACCESSMASK; 41 | m = mode; 42 | return setattrlist(path, &a, &m, sizeof(int), FSOPT_NOFOLLOW); 43 | } 44 | -------------------------------------------------------------------------------- /gen/FreeBSD/scandir_b.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2014 David Chisnall 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | * 26 | * $FreeBSD$ 27 | */ 28 | #ifdef __BLOCKS__ 29 | #define I_AM_SCANDIR_B 30 | #include "scandir.c" 31 | #endif /* __BLOCKS__ */ 32 | 33 | -------------------------------------------------------------------------------- /include/secure/_common.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007, 2008 Apple Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | #ifndef _SECURE__COMMON_H_ 25 | #define _SECURE__COMMON_H_ 26 | 27 | #undef _USE_FORTIFY_LEVEL 28 | #if defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0 29 | # if _FORTIFY_SOURCE > 1 30 | # define _USE_FORTIFY_LEVEL 2 31 | # else 32 | # define _USE_FORTIFY_LEVEL 1 33 | # endif 34 | #else 35 | # define _USE_FORTIFY_LEVEL 0 36 | #endif 37 | 38 | #define __darwin_obsz0(object) __builtin_object_size (object, 0) 39 | #define __darwin_obsz(object) __builtin_object_size (object, _USE_FORTIFY_LEVEL > 1 ? 1 : 0) 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /libdarwin/h/dirstat_collection.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Apple Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | __BEGIN_DECLS 29 | 30 | #pragma GCC visibility push(hidden) 31 | 32 | typedef struct dirstat_fileid_set_s dirstat_fileid_set_s; 33 | typedef dirstat_fileid_set_s *dirstat_fileid_set_t; 34 | 35 | dirstat_fileid_set_t _dirstat_fileid_set_create(void); 36 | void _dirstat_fileid_set_destroy(dirstat_fileid_set_t set); 37 | bool _dirstat_fileid_set_add(dirstat_fileid_set_t set, uint64_t fileid); 38 | 39 | #pragma GCC visibility pop 40 | 41 | __END_DECLS 42 | -------------------------------------------------------------------------------- /include/alloca.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2003 Apple Computer, Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | #ifndef _ALLOCA_H_ 25 | #define _ALLOCA_H_ 26 | 27 | #include 28 | #include <_types.h> 29 | #include 30 | 31 | #ifndef UNIFDEF_DRIVERKIT 32 | __BEGIN_DECLS 33 | void *alloca(size_t); /* built-in for gcc */ 34 | __END_DECLS 35 | #endif /* UNIFDEF_DRIVERKIT */ 36 | 37 | #if defined(__GNUC__) && __GNUC__ >= 3 38 | /* built-in for gcc 3 */ 39 | #undef alloca 40 | #undef __alloca 41 | #define alloca(size) __alloca(size) 42 | #define __alloca(size) __builtin_alloca(size) 43 | #endif 44 | 45 | #endif /* _ALLOCA_H_ */ 46 | -------------------------------------------------------------------------------- /include/xlocale/_string.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005 Apple Computer, Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | #ifndef _XLOCALE__STRING_H_ 25 | #define _XLOCALE__STRING_H_ 26 | 27 | #include 28 | #include 29 | #include <_xlocale.h> 30 | 31 | __BEGIN_DECLS 32 | int strcoll_l(const char *, const char *, locale_t); 33 | size_t strxfrm_l(char *, const char *, size_t, locale_t); 34 | int strcasecmp_l(const char *, const char *, locale_t); 35 | char *strcasestr_l(const char *, const char *, locale_t); 36 | int strncasecmp_l(const char *, const char *, size_t, locale_t); 37 | __END_DECLS 38 | 39 | #endif /* _XLOCALE__STRING_H_ */ 40 | -------------------------------------------------------------------------------- /emulated/lchflags.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005 Apple Computer, Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | int 31 | lchflags(const char *path, unsigned int flags) 32 | { 33 | struct stat s; 34 | struct attrlist a; 35 | 36 | if(lstat(path, &s) < 0) 37 | return -1; 38 | if((s.st_mode & S_IFMT) != S_IFLNK) 39 | return chflags(path, flags); 40 | bzero(&a, sizeof(a)); 41 | a.bitmapcount = ATTR_BIT_MAP_COUNT; 42 | a.commonattr = ATTR_CMN_FLAGS; 43 | return setattrlist(path, &a, &flags, sizeof(unsigned int), FSOPT_NOFOLLOW); 44 | } 45 | -------------------------------------------------------------------------------- /include/search.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Written by J.T. Conklin 3 | * Public domain. 4 | * 5 | * $NetBSD: search.h,v 1.12 1999/02/22 10:34:28 christos Exp $ 6 | * $FreeBSD: src/include/search.h,v 1.10 2002/10/16 14:29:23 robert Exp $ 7 | */ 8 | 9 | #ifndef _SEARCH_H_ 10 | #define _SEARCH_H_ 11 | 12 | #include 13 | #include <_types.h> 14 | #include 15 | 16 | typedef struct entry { 17 | char *key; 18 | void *data; 19 | } ENTRY; 20 | 21 | typedef enum { 22 | FIND, ENTER 23 | } ACTION; 24 | 25 | typedef enum { 26 | preorder, 27 | postorder, 28 | endorder, 29 | leaf 30 | } VISIT; 31 | 32 | #ifdef _SEARCH_PRIVATE 33 | typedef struct node { 34 | char *key; 35 | struct node *llink, *rlink; 36 | } node_t; 37 | 38 | struct que_elem { 39 | struct que_elem *next; 40 | struct que_elem *prev; 41 | }; 42 | #endif 43 | 44 | __BEGIN_DECLS 45 | int hcreate(size_t); 46 | void hdestroy(void); 47 | ENTRY *hsearch(ENTRY, ACTION); 48 | void insque(void *, void *); 49 | void *lfind(const void *, const void *, size_t *, size_t, 50 | int (*)(const void *, const void *)); 51 | void *lsearch(const void *, void *, size_t *, size_t, 52 | int (*)(const void *, const void *)); 53 | void remque(void *); 54 | void *tdelete(const void * __restrict, void ** __restrict, 55 | int (*)(const void *, const void *)); 56 | void *tfind(const void *, void * const *, 57 | int (*)(const void *, const void *)); 58 | void *tsearch(const void *, void **, int (*)(const void *, const void *)); 59 | void twalk(const void *, void (*)(const void *, VISIT, int)); 60 | __END_DECLS 61 | 62 | #endif /* !_SEARCH_H_ */ 63 | -------------------------------------------------------------------------------- /secure/memcpy_chk.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007-2013 Apple Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | #include 25 | #include 26 | #include "secure.h" 27 | 28 | void * 29 | __memcpy_chk (void *dest, const void *src, size_t len, size_t dstlen) 30 | { 31 | if (__builtin_expect (dstlen < len, 0)) 32 | __chk_fail_overflow (); 33 | 34 | /* On OS X, memcpy has supported overlapping buffers for many years. 35 | * While technically, this will catch buggy code, we should not abort. 36 | * if (__builtin_expect (__chk_assert_no_overlap != 0, 1)) 37 | * __chk_overlap(dest, len, src, len); 38 | */ 39 | 40 | return memcpy (dest, src, len); 41 | } 42 | -------------------------------------------------------------------------------- /string/strcat.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 Apple, Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | #include 25 | 26 | char * 27 | strcat(char *restrict dst, const char *restrict src) { 28 | const size_t dstlen = strlen(dst); 29 | const size_t srclen = strlen(src); 30 | // The strcat() and strncat() functions append a copy of the null- 31 | // terminated string src to the end of the null-terminated string dst, 32 | // then add a terminating '\0'. The string dst must have sufficient 33 | // space to hold the result. 34 | memcpy(dst+dstlen, src, srclen+1); 35 | // The strcat() and strncat() functions return dst. 36 | return dst; 37 | } 38 | -------------------------------------------------------------------------------- /secure/strcat_chk.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007-2013 Apple Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | #include 25 | #include 26 | #include 27 | #include "secure.h" 28 | 29 | char * 30 | __strcat_chk (char *__restrict dest, const char *__restrict append, 31 | size_t dstlen) 32 | { 33 | size_t len1 = strlen(dest); 34 | size_t len2 = strlen(append); 35 | 36 | if (__builtin_expect (dstlen < len1 + len2 + 1, 0)) 37 | __chk_fail_overflow (); 38 | 39 | if (__builtin_expect (__chk_assert_no_overlap != 0, 1)) 40 | __chk_overlap(dest, len1 + len2 + 1, append, len2 + 1); 41 | 42 | memcpy(dest + len1, append, len2 + 1); 43 | return dest; 44 | } 45 | -------------------------------------------------------------------------------- /secure/vsprintf_chk.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007-2013 Apple Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include "secure.h" 29 | 30 | int 31 | __vsprintf_chk (char *dest, int flags, size_t dstlen, const char *format, 32 | va_list arg) 33 | { 34 | int done; 35 | 36 | if (__builtin_expect (dstlen > (size_t) INT_MAX, 0)) 37 | done = vsprintf (dest, format, arg); 38 | else 39 | { 40 | done = vsnprintf (dest, dstlen, format, arg); 41 | if (__builtin_expect (done >= 0 && (size_t) done >= dstlen, 0)) 42 | __chk_fail_overflow (); 43 | } 44 | 45 | return done; 46 | } 47 | -------------------------------------------------------------------------------- /secure/memccpy_chk.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2013 Apple Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | #include 25 | #include 26 | #include "secure.h" 27 | 28 | void * 29 | __memccpy_chk (void *dest, const void *src, int c, size_t len, size_t dstlen) 30 | { 31 | void *retval; 32 | 33 | if (__builtin_expect (dstlen < len, 0)) 34 | __chk_fail_overflow (); 35 | 36 | /* retval is NULL if len was copied, otherwise retval is the 37 | * byte *after* the last one written. 38 | */ 39 | retval = memccpy (dest, src, c, len); 40 | 41 | if (retval != NULL) { 42 | len = (uintptr_t)retval - (uintptr_t)dest; 43 | } 44 | 45 | __chk_overlap(dest, len, src, len); 46 | 47 | return retval; 48 | } 49 | -------------------------------------------------------------------------------- /net/FreeBSD/sockatmark.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2002 William C. Fenner. All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 13 | * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS ``AS IS'' AND 14 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 16 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 17 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23 | * SUCH DAMAGE. 24 | * 25 | * $FreeBSD: src/lib/libc/net/sockatmark.c,v 1.1 2002/12/13 22:22:55 fenner Exp $ 26 | */ 27 | #include 28 | 29 | int sockatmark(int s) 30 | { 31 | int atmark; 32 | 33 | if (ioctl(s, SIOCATMARK, &atmark) == -1) 34 | return -1; 35 | return atmark; 36 | } 37 | -------------------------------------------------------------------------------- /stdlib/FreeBSD/llabs.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2001 Mike Barcroft 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | */ 26 | 27 | #include 28 | __FBSDID("$FreeBSD: src/lib/libc/stdlib/llabs.c,v 1.1 2001/11/15 02:05:03 mike Exp $"); 29 | 30 | #include 31 | 32 | long long 33 | llabs(long long j) 34 | { 35 | return (j < 0 ? -j : j); 36 | } 37 | -------------------------------------------------------------------------------- /stdlib/FreeBSD/imaxabs.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2001 Mike Barcroft 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | */ 26 | 27 | #include 28 | __FBSDID("$FreeBSD: src/lib/libc/stdlib/imaxabs.c,v 1.1 2001/11/15 02:05:03 mike Exp $"); 29 | 30 | #include 31 | 32 | intmax_t 33 | imaxabs(intmax_t j) 34 | { 35 | return (j < 0 ? -j : j); 36 | } 37 | -------------------------------------------------------------------------------- /i386/gen/mcount.s: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | #import 24 | 25 | .text 26 | .globl mcount 27 | mcount: 28 | pushl %ebp // setup mcount's frame 29 | movl %esp,%ebp 30 | 31 | movl (%ebp),%eax // load the frame pointer of mcount's caller 32 | movl 4(%eax),%eax // load mcount's caller's return address 33 | pushl 4(%ebp) // push the selfpc parameter for moncount() 34 | pushl %eax // push the frompc parameter for moncount() 35 | CALL_EXTERN(_moncount) // call moncount() 36 | 37 | movl %ebp,%esp // tear down mcount's frame 38 | popl %ebp 39 | ret 40 | -------------------------------------------------------------------------------- /secure/strncpy_chk.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007-2013 Apple Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | #include 25 | #include 26 | #include "secure.h" 27 | 28 | char * 29 | __strncpy_chk (char *restrict dest, char *restrict src, 30 | size_t len, size_t dstlen) 31 | { 32 | size_t n; 33 | 34 | if (__builtin_expect (dstlen < len, 0)) 35 | __chk_fail_overflow (); 36 | 37 | // stpncpy normally returns a pointer to the \0 38 | n = stpncpy (dest, src, len) - dest + 1; 39 | 40 | // Check if it's pointing to the location after the buffer after not writing \0 41 | if (n == len + 1) 42 | n--; 43 | 44 | if (__builtin_expect (__chk_assert_no_overlap != 0, 1)) 45 | __chk_overlap(dest, n, src, n); 46 | 47 | return dest; 48 | } 49 | -------------------------------------------------------------------------------- /emulated/lutimes.3: -------------------------------------------------------------------------------- 1 | .Dd Aug 13, 2006 2 | .Dt LUTIMES 3 3 | .Os 4 | .Sh NAME 5 | .Nm lutimes 6 | .Nd set file access and modification times of symlink 7 | .Sh SYNOPSIS 8 | .In sys/time.h 9 | .Ft int 10 | .Fn lutimes "const char *path" "struct timeval times[2]" 11 | .Sh DESCRIPTION 12 | The access and modification times of the file named by 13 | .Fa path 14 | are changed as specified by the argument 15 | .Fa times , 16 | even if 17 | .Fa path 18 | specifies a symbolic link (for 19 | .Xr utimes 2 20 | the times of the file referenced by the symbolic link are changed). 21 | .Pp 22 | If 23 | .Fa times 24 | is 25 | .Dv NULL , 26 | the access and modification times are set to the current time. 27 | The caller must be the owner of the file, have permission to 28 | write the file, or be the super-user. 29 | .Pp 30 | If 31 | .Fa times 32 | is 33 | .Pf non- Dv NULL , 34 | it is assumed to point to an array of two timeval structures. 35 | The access time is set to the value of the first element, and the 36 | modification time is set to the value of the second element. 37 | The caller must be the owner of the file or be the super-user. 38 | .Pp 39 | In either case, the inode-change-time of the file is set to the current 40 | time. 41 | .Sh NOTE 42 | Instead of being a system call, 43 | .Fn lutimes 44 | is emulated using 45 | .Xr setattrlist 2 . 46 | Not all file systems support 47 | .Xr setattrlist 2 . 48 | .Sh RETURN VALUES 49 | Upon successful completion, a value of 0 is returned. 50 | Otherwise, -1 is returned and the global variable 51 | .Va errno 52 | is set to indicate the error. 53 | .Sh ERRORS 54 | The 55 | .Fn lutimes 56 | call may return the same errors as 57 | .Xr utimes 2 58 | and 59 | .Xr setattrlist 2 . 60 | .Sh SEE ALSO 61 | .Xr utimes 2 , 62 | .Xr setattrlist 2 63 | -------------------------------------------------------------------------------- /include/_types/_intmax_t.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 Apple Inc. All rights reserved. 3 | * 4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. The rights granted to you under the License 10 | * may not be used to create, or enable the creation or redistribution of, 11 | * unlawful or unlicensed copies of an Apple operating system, or to 12 | * circumvent, violate, or enable the circumvention or violation of, any 13 | * terms of an Apple operating system software license agreement. 14 | * 15 | * Please obtain a copy of the License at 16 | * http://www.opensource.apple.com/apsl/ and read it before using this file. 17 | * 18 | * The Original Code and all software distributed under the License are 19 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 23 | * Please see the License for the specific language governing rights and 24 | * limitations under the License. 25 | * 26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ 27 | */ 28 | 29 | #ifndef _INTMAX_T 30 | #define _INTMAX_T 31 | #ifdef __INTMAX_TYPE__ 32 | typedef __INTMAX_TYPE__ intmax_t; 33 | #else 34 | #ifdef __LP64__ 35 | typedef long int intmax_t; 36 | #else 37 | typedef long long int intmax_t; 38 | #endif /* __LP64__ */ 39 | #endif /* __INTMAX_TYPE__ */ 40 | #endif /* _INTMAX_T */ 41 | -------------------------------------------------------------------------------- /tests/os_simple_hash.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | T_DECL(os_simple_hash, "sanity check of os_simple_hash", 6 | T_META_ALL_VALID_ARCHS(true)) 7 | { 8 | const char * string = 9 | "We made the buttons on the screen look so good you'll want to lick them."; 10 | uint64_t hashval = os_simple_hash_string(string); 11 | T_EXPECT_NE(hashval, 0ULL, "usually should get a non-0 hash value"); 12 | 13 | char buf[1024]; 14 | arc4random_buf(buf, sizeof(buf)); 15 | hashval = os_simple_hash(buf, sizeof(buf)); 16 | T_EXPECT_NE(hashval, 0ULL, "usually should get a non-0 hash value"); 17 | } 18 | 19 | T_DECL(os_simple_hash_seeds, "os_simple_hash different seeds give different hashes", 20 | T_META_ALL_VALID_ARCHS(true)) 21 | { 22 | const char * string = 23 | "We made the buttons on the screen look so good you'll want to lick them."; 24 | 25 | uint64_t hashval0 = os_simple_hash_string_with_seed(string, 0x0); 26 | T_EXPECT_NE(hashval0, 0ULL, "usually should get a non-0 hash value"); 27 | uint64_t hashval1 = os_simple_hash_string_with_seed(string, 0x1); 28 | T_EXPECT_NE(hashval1, 0ULL, "usually should get a non-0 hash value"); 29 | uint64_t hashvalF = os_simple_hash_string_with_seed(string, 0xF); 30 | T_EXPECT_NE(hashvalF, 0ULL, "usually should get a non-0 hash value"); 31 | uint64_t hashvalFoo = os_simple_hash_string_with_seed(string, 0xF0000000); 32 | T_EXPECT_NE(hashvalFoo, 0ULL, "usually should get a non-0 hash value"); 33 | 34 | T_EXPECT_NE(hashval0, hashval1, NULL); 35 | T_EXPECT_NE(hashval0, hashvalF, NULL); 36 | T_EXPECT_NE(hashval0, hashvalFoo, NULL); 37 | T_EXPECT_NE(hashval1, hashvalF, NULL); 38 | T_EXPECT_NE(hashval1, hashvalFoo, NULL); 39 | T_EXPECT_NE(hashvalF, hashvalFoo, NULL); 40 | } 41 | -------------------------------------------------------------------------------- /secure/stpncpy_chk.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2013 Apple Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | #include 25 | #include 26 | #include "secure.h" 27 | 28 | char * 29 | __stpncpy_chk (char *restrict dest, char *restrict src, 30 | size_t len, size_t dstlen) 31 | { 32 | size_t n; 33 | char *retval; 34 | 35 | if (__builtin_expect (dstlen < len, 0)) 36 | __chk_fail_overflow (); 37 | 38 | retval = stpncpy (dest, src, len); // Normally returns a pointer to the \0 39 | n = retval - dest + 1; 40 | 41 | // Check if it's pointing to the location after the buffer after not writing \0 42 | if (n == len + 1) 43 | n--; 44 | 45 | if (__builtin_expect (__chk_assert_no_overlap != 0, 1)) 46 | __chk_overlap(dest, n, src, n); 47 | 48 | return retval; 49 | } 50 | -------------------------------------------------------------------------------- /secure/strncat_chk.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007-2013 Apple Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | #include 25 | #include 26 | #include "secure.h" 27 | 28 | char * 29 | __strncat_chk (char *restrict dest, const char *restrict append, 30 | size_t len, size_t dstlen) 31 | { 32 | size_t len1 = strlen(dest); 33 | size_t len2 = strnlen(append, len); 34 | 35 | if (__builtin_expect (dstlen < len1 + len2 + 1, 0)) 36 | __chk_fail_overflow (); 37 | 38 | if (__builtin_expect (__chk_assert_no_overlap != 0, 1)) 39 | __chk_overlap(dest, len1 + len2 + 1, append, len2 + 1); 40 | 41 | /* memmove() all but the NUL, since it might not actually be NUL */ 42 | memcpy(dest + len1, append, len2); 43 | dest[len1 + len2] = '\0'; 44 | 45 | return dest; 46 | } 47 | -------------------------------------------------------------------------------- /include/_types/_uintmax_t.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 Apple Inc. All rights reserved. 3 | * 4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. The rights granted to you under the License 10 | * may not be used to create, or enable the creation or redistribution of, 11 | * unlawful or unlicensed copies of an Apple operating system, or to 12 | * circumvent, violate, or enable the circumvention or violation of, any 13 | * terms of an Apple operating system software license agreement. 14 | * 15 | * Please obtain a copy of the License at 16 | * http://www.opensource.apple.com/apsl/ and read it before using this file. 17 | * 18 | * The Original Code and all software distributed under the License are 19 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 23 | * Please see the License for the specific language governing rights and 24 | * limitations under the License. 25 | * 26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ 27 | */ 28 | 29 | #ifndef _UINTMAX_T 30 | #define _UINTMAX_T 31 | #ifdef __UINTMAX_TYPE__ 32 | typedef __UINTMAX_TYPE__ uintmax_t; 33 | #else 34 | #ifdef __LP64__ 35 | typedef long unsigned int uintmax_t; 36 | #else 37 | typedef long long unsigned int uintmax_t; 38 | #endif /* __LP64__ */ 39 | #endif /* __UINTMAX_TYPE__ */ 40 | #endif /* _UINTMAX_T */ 41 | -------------------------------------------------------------------------------- /include/crt_externs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | /* 24 | * Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved 25 | */ 26 | 27 | /* 28 | ** Prototypes for the functions to get environment information in 29 | ** the world of dynamic libraries. Lifted from .c file of same name. 30 | ** Fri Jun 23 12:56:47 PDT 1995 31 | ** AOF (afreier@next.com) 32 | */ 33 | 34 | #include 35 | 36 | __BEGIN_DECLS 37 | extern char ***_NSGetArgv(void); 38 | extern int *_NSGetArgc(void); 39 | extern char ***_NSGetEnviron(void); 40 | extern char **_NSGetProgname(void); 41 | #ifdef __LP64__ 42 | extern struct mach_header_64 * 43 | #else /* !__LP64__ */ 44 | extern struct mach_header * 45 | #endif /* __LP64__ */ 46 | _NSGetMachExecuteHeader(void); 47 | __END_DECLS 48 | -------------------------------------------------------------------------------- /include/ulimit.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2002 Kyle Martin 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | * 26 | * $FreeBSD: src/include/ulimit.h,v 1.4 2003/01/08 01:18:13 tjr Exp $ 27 | */ 28 | 29 | #ifndef _ULIMIT_H_ 30 | #define _ULIMIT_H_ 31 | 32 | #include 33 | 34 | #define UL_GETFSIZE 1 35 | #define UL_SETFSIZE 2 36 | 37 | __BEGIN_DECLS 38 | long ulimit(int, ...); 39 | __END_DECLS 40 | 41 | #endif /* !_ULIMIT_H_ */ 42 | -------------------------------------------------------------------------------- /stdlib/FreeBSD/tsearch.c: -------------------------------------------------------------------------------- 1 | /* $NetBSD: tsearch.c,v 1.3 1999/09/16 11:45:37 lukem Exp $ */ 2 | 3 | /* 4 | * Tree search generalized from Knuth (6.2.2) Algorithm T just like 5 | * the AT&T man page says. 6 | * 7 | * The node_t structure is for internal use only, lint doesn't grok it. 8 | * 9 | * Written by reading the System V Interface Definition, not the code. 10 | * 11 | * Totally public domain. 12 | */ 13 | 14 | #include 15 | #if 0 16 | #if defined(LIBC_SCCS) && !defined(lint) 17 | __RCSID("$NetBSD: tsearch.c,v 1.3 1999/09/16 11:45:37 lukem Exp $"); 18 | #endif /* LIBC_SCCS and not lint */ 19 | #endif 20 | __FBSDID("$FreeBSD: src/lib/libc/stdlib/tsearch.c,v 1.4 2003/01/05 02:43:18 tjr Exp $"); 21 | 22 | #define _SEARCH_PRIVATE 23 | #include 24 | #include 25 | 26 | /* find or insert datum into search tree */ 27 | void * 28 | tsearch(vkey, vrootp, compar) 29 | const void *vkey; /* key to be located */ 30 | void **vrootp; /* address of tree root */ 31 | int (*compar)(const void *, const void *); 32 | { 33 | node_t *q; 34 | node_t **rootp = (node_t **)vrootp; 35 | 36 | if (rootp == NULL) 37 | return NULL; 38 | 39 | while (*rootp != NULL) { /* Knuth's T1: */ 40 | int r; 41 | 42 | if ((r = (*compar)(vkey, (*rootp)->key)) == 0) /* T2: */ 43 | return *rootp; /* we found it! */ 44 | 45 | rootp = (r < 0) ? 46 | &(*rootp)->llink : /* T3: follow left branch */ 47 | &(*rootp)->rlink; /* T4: follow right branch */ 48 | } 49 | 50 | q = malloc(sizeof(node_t)); /* T5: key not found */ 51 | if (q != 0) { /* make new node */ 52 | *rootp = q; /* link new node to old */ 53 | /* LINTED const castaway ok */ 54 | q->key = (void *)vkey; /* initialize new node */ 55 | q->llink = q->rlink = NULL; 56 | } 57 | return q; 58 | } 59 | -------------------------------------------------------------------------------- /stdlib/FreeBSD/twalk.c: -------------------------------------------------------------------------------- 1 | /* $NetBSD: twalk.c,v 1.1 1999/02/22 10:33:16 christos Exp $ */ 2 | 3 | /* 4 | * Tree search generalized from Knuth (6.2.2) Algorithm T just like 5 | * the AT&T man page says. 6 | * 7 | * The node_t structure is for internal use only, lint doesn't grok it. 8 | * 9 | * Written by reading the System V Interface Definition, not the code. 10 | * 11 | * Totally public domain. 12 | */ 13 | 14 | #include 15 | #if 0 16 | #if defined(LIBC_SCCS) && !defined(lint) 17 | __RCSID("$NetBSD: twalk.c,v 1.1 1999/02/22 10:33:16 christos Exp $"); 18 | #endif /* LIBC_SCCS and not lint */ 19 | #endif 20 | __FBSDID("$FreeBSD: src/lib/libc/stdlib/twalk.c,v 1.5 2003/01/05 02:43:18 tjr Exp $"); 21 | 22 | #define _SEARCH_PRIVATE 23 | #include 24 | #include 25 | 26 | static void trecurse(const node_t *, 27 | void (*action)(const void *, VISIT, int), int level); 28 | 29 | /* Walk the nodes of a tree */ 30 | static void 31 | trecurse(root, action, level) 32 | const node_t *root; /* Root of the tree to be walked */ 33 | void (*action)(const void *, VISIT, int); 34 | int level; 35 | { 36 | 37 | if (root->llink == NULL && root->rlink == NULL) 38 | (*action)(root, leaf, level); 39 | else { 40 | (*action)(root, preorder, level); 41 | if (root->llink != NULL) 42 | trecurse(root->llink, action, level + 1); 43 | (*action)(root, postorder, level); 44 | if (root->rlink != NULL) 45 | trecurse(root->rlink, action, level + 1); 46 | (*action)(root, endorder, level); 47 | } 48 | } 49 | 50 | /* Walk the nodes of a tree */ 51 | void 52 | twalk(vroot, action) 53 | const void *vroot; /* Root of the tree to be walked */ 54 | void (*action)(const void *, VISIT, int); 55 | { 56 | if (vroot != NULL && action != NULL) 57 | trecurse(vroot, action, 0); 58 | } 59 | -------------------------------------------------------------------------------- /sys/umaskx_np.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004 Apple Computer, Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | extern int __umask_extended(int, acl_t); 30 | 31 | int 32 | umaskx_np(filesec_t fsec) 33 | { 34 | acl_t acl = NULL; 35 | size_t size = 0; 36 | mode_t newmask = 0; 37 | 38 | if (fsec) 39 | { 40 | if ((filesec_get_property(fsec, FILESEC_MODE, &newmask) != 0) && (errno != ENOENT)) 41 | return(-1); 42 | 43 | if (((filesec_get_property(fsec, FILESEC_ACL_RAW, &acl) != 0) || 44 | (filesec_get_property(fsec, FILESEC_ACL_ALLOCSIZE, &size) != 0)) && 45 | (errno != ENOENT)) 46 | return(-1); 47 | if (size == 0) 48 | acl = NULL; 49 | } 50 | return __umask_extended(newmask, acl); 51 | } 52 | -------------------------------------------------------------------------------- /string/FreeBSD/wcschr.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2002 Tim J. Robbins 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | */ 26 | 27 | #include 28 | __FBSDID("$FreeBSD: src/lib/libc/string/wcschr.c,v 1.7 2002/10/23 10:47:47 tjr Exp $"); 29 | 30 | #include 31 | 32 | wchar_t * 33 | wcschr(const wchar_t *s, wchar_t c) 34 | { 35 | 36 | while (*s != c && *s != L'\0') 37 | s++; 38 | if (*s == c) 39 | return ((wchar_t *)s); 40 | return (NULL); 41 | } 42 | -------------------------------------------------------------------------------- /tests/printf.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #include "darwintest.h" 12 | #include "darwintest_utils.h" 13 | 14 | static void crash_callback(const char *str) { 15 | T_PASS("Crashed with \"%s\"", str); 16 | T_END; 17 | } 18 | 19 | T_DECL(sprintf_percent_n, "Test of %n") 20 | { 21 | char str[1024]; 22 | int len, ret; 23 | 24 | char *fmt = "%010d%n"; 25 | 26 | T_EXPECT_POSIX_SUCCESS((ret = snprintf(str, sizeof(str), fmt, 0, &len)), NULL); 27 | T_EXPECT_EQ(len, ret, NULL); 28 | 29 | char fmt_buf[32]; 30 | strlcpy(fmt_buf, fmt, sizeof(fmt_buf)); 31 | 32 | os_set_crash_callback(crash_callback); 33 | snprintf(str, sizeof(str), fmt_buf, 0, &len); 34 | T_ASSERT_FAIL("Should have crashed on dynamic %%n"); 35 | } 36 | 37 | #if !TARGET_OS_IPHONE 38 | #define STRSIZE (1024 * 1024 * 256) 39 | 40 | T_DECL(printf_PR_30663523, "Test for PR-30663523", 41 | T_META_CHECK_LEAKS(NO)) 42 | { 43 | char *temp_path; 44 | asprintf(&temp_path, "%s/%s", dt_tmpdir(), "big_file"); 45 | 46 | { 47 | char *x = calloc(1, 0x80000001); 48 | memset(x, 0x41, 0x80000001); 49 | 50 | FILE *f = fopen(temp_path, "w"); 51 | int len = fprintf(f, "%s", x); 52 | T_EXPECT_EQ(len, EOF, "fprintf should return EOF when string is longer than INT_MAX"); 53 | fclose(f); 54 | } 55 | 56 | { 57 | char *x = calloc(1, STRSIZE); 58 | memset(x, 0x41, STRSIZE - 1); 59 | 60 | FILE *f = fopen(temp_path, "w"); 61 | int len = fprintf(f, "%s%s%s%s%s%s%s%s%s%s", x,x,x,x,x,x,x,x,x,x); 62 | T_EXPECT_EQ(len, EOF, "fprintf should return EOF when output string is longer than INT_MAX"); 63 | fclose(f); 64 | } 65 | } 66 | #endif // !TARGET_OS_IPHONE 67 | -------------------------------------------------------------------------------- /tests/qsort.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Randomized test for qsort() routine. 3 | */ 4 | 5 | #include 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #include "freebsd_qsort.h" 14 | 15 | #define BUFLEN (32 * 1024) 16 | 17 | static int tests = 10; 18 | 19 | T_DECL(qsort_random, "qsort random test", T_META_CHECK_LEAKS(NO)) 20 | { 21 | char testvector[BUFLEN]; 22 | char sresvector[BUFLEN]; 23 | size_t i; 24 | 25 | while (--tests >= 0) { 26 | size_t elmsize = (tests % 32) + 1; 27 | size_t elmcount = sizeof(testvector) / elmsize; 28 | T_LOG("%d: size = %zu, count = %zu", tests, elmsize, elmcount); 29 | 30 | /* Populate test vectors */ 31 | arc4random_buf(testvector, sizeof(testvector)); 32 | memcpy(sresvector, testvector, sizeof(testvector)); 33 | 34 | /* Sort using qsort(3) */ 35 | qsort_r(testvector, elmcount, elmsize, (void*)elmsize, szsorthelp); 36 | /* Sort using reference slow sorting routine */ 37 | szsort(sresvector, elmcount, elmsize); 38 | 39 | /* Compare results */ 40 | for (i = 0; i < elmcount; i++){ 41 | if (memcmp(testvector + (i * elmsize), sresvector + (i * elmsize), elmsize) != 0) { 42 | T_LOG("testvector ="); 43 | dt_print_hex_dump((uint8_t*)testvector, sizeof(testvector)); 44 | T_LOG("sresvector ="); 45 | dt_print_hex_dump((uint8_t*)sresvector, sizeof(sresvector)); 46 | T_ASSERT_FAIL("%d: item at index %zd should match", tests, i); 47 | break; 48 | } 49 | } 50 | if (i == elmcount) { 51 | T_PASS("%d: Sorted successfully.", tests); 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /include/readpassphrase.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2000, 2002 Todd C. Miller 3 | * 4 | * Permission to use, copy, modify, and distribute this software for any 5 | * purpose with or without fee is hereby granted, provided that the above 6 | * copyright notice and this permission notice appear in all copies. 7 | * 8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 9 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 10 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 11 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 12 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 13 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15 | * 16 | * Sponsored in part by the Defense Advanced Research Projects 17 | * Agency (DARPA) and Air Force Research Laboratory, Air Force 18 | * Materiel Command, USAF, under agreement number F39502-99-1-0512. 19 | */ 20 | 21 | #ifndef _READPASSPHRASE_H_ 22 | #define _READPASSPHRASE_H_ 23 | 24 | #define RPP_ECHO_OFF 0x00 /* Turn off echo (default). */ 25 | #define RPP_ECHO_ON 0x01 /* Leave echo on. */ 26 | #define RPP_REQUIRE_TTY 0x02 /* Fail if there is no tty. */ 27 | #define RPP_FORCELOWER 0x04 /* Force input to lower case. */ 28 | #define RPP_FORCEUPPER 0x08 /* Force input to upper case. */ 29 | #define RPP_SEVENBIT 0x10 /* Strip the high bit from input. */ 30 | #define RPP_STDIN 0x20 /* Read from stdin, not /dev/tty */ 31 | 32 | #include <_types.h> 33 | #include 34 | 35 | __BEGIN_DECLS 36 | char * readpassphrase(const char *, char *, size_t, int); 37 | __END_DECLS 38 | 39 | #endif /* !_READPASSPHRASE_H_ */ 40 | -------------------------------------------------------------------------------- /gen/utmpx_thread.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010 Apple Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * "Portions Copyright (c) 2004 Apple Computer, Inc. All Rights 7 | * Reserved. This file contains Original Code and/or Modifications of 8 | * Original Code as defined in and that are subject to the Apple Public 9 | * Source License Version 1.0 (the 'License'). You may not use this file 10 | * except in compliance with the License. Please obtain a copy of the 11 | * License at http://www.apple.com/publicsource and read it before using 12 | * this file. 13 | * 14 | * The Original Code and all software distributed under the License are 15 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 16 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 17 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the 19 | * License for the specific language governing rights and limitations 20 | * under the License." 21 | * 22 | * @APPLE_LICENSE_HEADER_END@ 23 | */ 24 | 25 | /* 26 | * Thread-aware utmpx SPI 27 | */ 28 | #ifndef _UTMPX_THREAD_H_ 29 | #define _UTMPX_THREAD_H_ 30 | 31 | #include 32 | 33 | struct _utmpx; /* forward reference */ 34 | typedef struct _utmpx *utmpx_t; 35 | 36 | __BEGIN_DECLS 37 | int _closeutx(utmpx_t); 38 | void _endutxent(utmpx_t); 39 | struct utmpx *_getutxent(utmpx_t); 40 | struct utmpx *_getutxid(utmpx_t, const struct utmpx *); 41 | struct utmpx *_getutxline(utmpx_t, const struct utmpx *); 42 | utmpx_t _openutx(const char *); 43 | struct utmpx *_pututxline(utmpx_t, const struct utmpx *); 44 | void _setutxent(utmpx_t); 45 | int _utmpxname(utmpx_t, const char *); 46 | __END_DECLS 47 | 48 | #endif /* !_UTMPX_THREAD_H_ */ 49 | -------------------------------------------------------------------------------- /string/FreeBSD/wcsnlen.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2009 David Schultz 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | */ 26 | 27 | #include 28 | __FBSDID("$FreeBSD: src/lib/libc/string/wcsnlen.c,v 1.1 2009/02/28 06:00:58 das Exp $"); 29 | 30 | #include 31 | 32 | size_t 33 | wcsnlen(const wchar_t *s, size_t maxlen) 34 | { 35 | size_t len; 36 | 37 | for (len = 0; len < maxlen; len++, s++) { 38 | if (!*s) 39 | break; 40 | } 41 | return (len); 42 | } 43 | -------------------------------------------------------------------------------- /stdio/FreeBSD/getline.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2009 David Schultz 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | */ 26 | 27 | #include 28 | __FBSDID("$FreeBSD: src/lib/libc/stdio/getline.c,v 1.1 2009/02/28 06:00:58 das Exp $"); 29 | 30 | #define _WITH_GETLINE 31 | #include 32 | 33 | ssize_t 34 | getline(char ** __restrict linep, size_t * __restrict linecapp, 35 | FILE * __restrict fp) 36 | { 37 | 38 | return (getdelim(linep, linecapp, '\n', fp)); 39 | } 40 | -------------------------------------------------------------------------------- /xcodescripts/eos.xcconfig: -------------------------------------------------------------------------------- 1 | #include "libc.xcconfig" 2 | 3 | BUILD_ARCHIVES = Base FreeBSD TRE vCancelable vDarwinExtsn 4 | BUILD_VARIANTS = normal 5 | EXECUTABLE_PREFIX = lib 6 | INSTALL_PATH = /usr/local/lib/eOS 7 | OTHER_LIBTOOLFLAGS = -filelist $(BUILT_PRODUCTS_DIR)/$(CURRENT_VARIANT).linklist.libtool 8 | PRODUCT_NAME = c_eOS 9 | SKIP_INSTALL = YES 10 | SKIP_INSTALL[sdk=iphoneos*] = NO 11 | STRIP_INSTALLED_PRODUCT = NO 12 | VARIANT = EOS 13 | VERSIONING_SYSTEM = apple-generic 14 | 15 | // Variants. All variants contain all source files but all excluded. Specific variants then include the files they need. 16 | EXCLUDED_SOURCE_FILE_NAMES = * 17 | EXCLUDED_SOURCE_FILE_NAMES[sdk=iphoneos*] = $(VARIANT_EOS_EXCLUDED_FILES) 18 | EXCLUDED_SOURCE_FILE_NAMES[sdk=watchos*] = $(VARIANT_EOS_EXCLUDED_FILES) 19 | EXCLUDED_SOURCE_FILE_NAMES[sdk=appletvos*] = $(VARIANT_EOS_EXCLUDED_FILES) 20 | EXCLUDED_SOURCE_FILE_NAMES[sdk=bridgeos*] = $(VARIANT_EOS_EXCLUDED_FILES) 21 | INCLUDED_SOURCE_FILE_NAMES = 22 | INCLUDED_SOURCE_FILE_NAMES[sdk=iphoneos*] = $(VARIANT_EOS_INCLUDED_FILES) 23 | INCLUDED_SOURCE_FILE_NAMES[sdk=watchos*] = $(VARIANT_EOS_INCLUDED_FILES) 24 | INCLUDED_SOURCE_FILE_NAMES[sdk=appletvos*] = $(VARIANT_EOS_INCLUDED_FILES) 25 | INCLUDED_SOURCE_FILE_NAMES[sdk=bridgeos*] = $(VARIANT_EOS_INCLUDED_FILES) 26 | VARIANT_PREPROCESSOR_MACROS = -UBUILDING_VARIANT -DVARIANT_STATIC -DVARIANT_EOS -DVARIANT_CANCELABLE -DVARIANT_DARWINEXTSN -U__DARWIN_NON_CANCELABLE -D__DARWIN_NON_CANCELABLE=0 27 | 28 | SYSTEM_FRAMEWORK_HEADERS = $(DERIVED_FILES_DIR)/System.framework/Versions/B/PrivateHeaders 29 | HEADER_SEARCH_PATHS = $(FreeBSD_SEARCH_PATHS) $(inherited) 30 | 31 | // EOS (libc_eOS.a) 32 | VARIANT_EOS_EXCLUDED_FILES = * 33 | VARIANT_EOS_INCLUDED_FILES = secure/*.c $(ARCH_FAMILY_$(CURRENT_ARCH))/*/*.c $(ARCH_FAMILY_$(CURRENT_ARCH))/*/*.S $(ARCH_FAMILY_$(CURRENT_ARCH))/*/*.s 34 | --------------------------------------------------------------------------------