gen/FreeBSD/readpassphrase.c freebsd lib/libc/gen/readpassphrase.c 1f19a8fc755a14865a5a5b67d5fa895c4b7cf622
gen/FreeBSD/readpassphrase.3 freebsd lib/libc/gen/readpassphrase.3 e0a2d4f15ed9e93fcb62544ed65f7a98e2339c3b
gen/FreeBSD/times.3 freebsd lib/libc/gen/times.3 5b882020081a138285227631c46a406c08e17bc8
+gen/FreeBSD/ttyname.3 freebsd lib/libc/gen/ttyname.3 84be924362c6e5f469564d418c928c5b1b4a2457
gen/FreeBSD/ttyslot.c freebsd lib/libc/gen/ttyslot.c 898928e8d0a0bab201c1ef232e01cafa27322dae
gen/FreeBSD/unvis.c freebsd contrib/libc-vis/unvis.c 9e3e4b88576d01efe1f56469cac79e116bb62c67
gen/FreeBSD/unvis.3 freebsd contrib/libc-vis/unvis.3 9e3e4b88576d01efe1f56469cac79e116bb62c67
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
-.\" 4. Neither the name of the University nor the names of its contributors
+.\" 3. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
.El
.Sh SEE ALSO
.Xr ioctl 2 ,
+.Xr ptsname 3 ,
+.Xr tcgetattr 3 ,
+.Xr tty 4 ,
.Xr ttys 5
.Sh HISTORY
The
.Va errno
may be set to any of the values documented for the
.Xr getdirentries 2
-system call.
+system call. Note that the order of the directory entries vended by
+.Fn readdir
+is not specified. Some filesystems may return entries in lexicographic sort order and others may not.
.Pp
The
.Fn readdir_r
--- /dev/null
+/*
+ * Copyright (c) 2017 Apple Inc. All rights reserved.
+ *
+ * @APPLE_LICENSE_HEADER_START@
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ *
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
+ *
+ * @APPLE_LICENSE_HEADER_END@
+ */
+/*-
+ * Copyright (c)1999 Citrus Project,
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ */
+
+/*
+ * Common header for _wctype.h and xlocale/__wctype.h
+ */
+
+#ifndef ___WCTYPE_H_
+#define ___WCTYPE_H_
+
+#include <sys/cdefs.h>
+#include <_types.h>
+
+#include <sys/_types/_wint_t.h>
+#include <sys/_types/_wint_t.h>
+#include <_types/_wctype_t.h>
+
+#ifndef WEOF
+#define WEOF __DARWIN_WEOF
+#endif
+
+#ifndef __DARWIN_WCTYPE_TOP_inline
+#define __DARWIN_WCTYPE_TOP_inline __header_inline
+#endif
+
+#include <ctype.h>
+
+#endif /* ___WCTYPE_H_ */
--- /dev/null
+/*
+ * Copyright (c) 2000, 2005, 2008 Apple Inc. All rights reserved.
+ *
+ * @APPLE_LICENSE_HEADER_START@
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ *
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
+ *
+ * @APPLE_LICENSE_HEADER_END@
+ */
+/*
+ * Copyright (c) 1989, 1993
+ * The Regents of the University of California. All rights reserved.
+ * (c) UNIX System Laboratories, Inc.
+ * All or some portions of this file are derived from material licensed
+ * to the University of California by American Telephone and Telegraph
+ * Co. or Unix System Laboratories, Inc. and are reproduced herein with
+ * the permission of UNIX System Laboratories, Inc.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Paul Borman at Krystal Technologies.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)ctype.h 8.4 (Berkeley) 1/21/94
+ */
+
+//Begin-Libc
+#include "xlocale_private.h"
+//End-Libc
+#ifndef __CTYPE_H_
+#define __CTYPE_H_
+
+#include <sys/cdefs.h>
+#include <runetype.h>
+
+#define _CTYPE_A 0x00000100L /* Alpha */
+#define _CTYPE_C 0x00000200L /* Control */
+#define _CTYPE_D 0x00000400L /* Digit */
+#define _CTYPE_G 0x00000800L /* Graph */
+#define _CTYPE_L 0x00001000L /* Lower */
+#define _CTYPE_P 0x00002000L /* Punct */
+#define _CTYPE_S 0x00004000L /* Space */
+#define _CTYPE_U 0x00008000L /* Upper */
+#define _CTYPE_X 0x00010000L /* X digit */
+#define _CTYPE_B 0x00020000L /* Blank */
+#define _CTYPE_R 0x00040000L /* Print */
+#define _CTYPE_I 0x00080000L /* Ideogram */
+#define _CTYPE_T 0x00100000L /* Special */
+#define _CTYPE_Q 0x00200000L /* Phonogram */
+#define _CTYPE_SW0 0x20000000L /* 0 width character */
+#define _CTYPE_SW1 0x40000000L /* 1 width character */
+#define _CTYPE_SW2 0x80000000L /* 2 width character */
+#define _CTYPE_SW3 0xc0000000L /* 3 width character */
+#define _CTYPE_SWM 0xe0000000L /* Mask for screen width data */
+#define _CTYPE_SWS 30 /* Bits to shift to get width */
+
+#ifdef _NONSTD_SOURCE
+/*
+ * Backward compatibility
+ */
+#define _A _CTYPE_A /* Alpha */
+#define _C _CTYPE_C /* Control */
+#define _D _CTYPE_D /* Digit */
+#define _G _CTYPE_G /* Graph */
+#define _L _CTYPE_L /* Lower */
+#define _P _CTYPE_P /* Punct */
+#define _S _CTYPE_S /* Space */
+#define _U _CTYPE_U /* Upper */
+#define _X _CTYPE_X /* X digit */
+#define _B _CTYPE_B /* Blank */
+#define _R _CTYPE_R /* Print */
+#define _I _CTYPE_I /* Ideogram */
+#define _T _CTYPE_T /* Special */
+#define _Q _CTYPE_Q /* Phonogram */
+#define _SW0 _CTYPE_SW0 /* 0 width character */
+#define _SW1 _CTYPE_SW1 /* 1 width character */
+#define _SW2 _CTYPE_SW2 /* 2 width character */
+#define _SW3 _CTYPE_SW3 /* 3 width character */
+#endif /* _NONSTD_SOURCE */
+
+//Begin-Libc
+/*
+ * _EXTERNALIZE_CTYPE_INLINES_ is defined in locale/nomacros.c to tell us
+ * to generate code for extern versions of all intermediate inline functions.
+ */
+#ifdef _EXTERNALIZE_CTYPE_INLINES_
+#define _USE_CTYPE_INLINE_
+#define __DARWIN_CTYPE_inline
+#else /* !_EXTERNALIZE_CTYPE_INLINES_ */
+//End-Libc
+#define __DARWIN_CTYPE_inline __header_inline
+//Begin-Libc
+#endif /* !_EXTERNALIZE_CTYPE_INLINES_ */
+//End-Libc
+
+//Begin-Libc
+/*
+ * _EXTERNALIZE_CTYPE_INLINES_TOP_ is defined in locale/isctype.c to tell us
+ * to generate code for extern versions of all top-level inline functions.
+ */
+#ifdef _EXTERNALIZE_CTYPE_INLINES_TOP_
+#define _USE_CTYPE_INLINE_
+#define __DARWIN_CTYPE_TOP_inline
+#else /* !_EXTERNALIZE_CTYPE_INLINES_TOP_ */
+//End-Libc
+#define __DARWIN_CTYPE_TOP_inline __header_inline
+//Begin-Libc
+#endif /* _EXTERNALIZE_CTYPE_INLINES_TOP_ */
+//End-Libc
+
+/*
+ * Use inline functions if we are allowed to and the compiler supports them.
+ */
+#if !defined(_DONT_USE_CTYPE_INLINE_) && \
+ (defined(_USE_CTYPE_INLINE_) || defined(__GNUC__) || defined(__cplusplus))
+
+/* See comments in <machine/_type.h> about __darwin_ct_rune_t. */
+__BEGIN_DECLS
+unsigned long ___runetype(__darwin_ct_rune_t);
+__darwin_ct_rune_t ___tolower(__darwin_ct_rune_t);
+__darwin_ct_rune_t ___toupper(__darwin_ct_rune_t);
+__END_DECLS
+
+__DARWIN_CTYPE_TOP_inline int
+isascii(int _c)
+{
+ return ((_c & ~0x7F) == 0);
+}
+
+#ifdef USE_ASCII
+__DARWIN_CTYPE_inline int
+__maskrune(__darwin_ct_rune_t _c, unsigned long _f)
+{
+ return (int)_DefaultRuneLocale.__runetype[_c & 0xff] & (__uint32_t)_f;
+}
+//Begin-Libc
+#elif defined(__LIBC__)
+__DARWIN_CTYPE_inline int
+__maskrune(__darwin_ct_rune_t _c, unsigned long _f)
+{
+ /* _CurrentRuneLocale.__runetype[_c] is __uint32_t
+ * _f is unsigned long
+ * ___runetype(_c) is unsigned long
+ * retval is int
+ */
+ return (int)((_c < 0 || _c >= _CACHED_RUNES) ? (__uint32_t)___runetype(_c) :
+ __current_locale()->__lc_ctype->_CurrentRuneLocale.__runetype[_c]) & (__uint32_t)_f;
+}
+//End-Libc
+#else /* !USE_ASCII */
+__BEGIN_DECLS
+int __maskrune(__darwin_ct_rune_t, unsigned long);
+__END_DECLS
+#endif /* USE_ASCII */
+
+__DARWIN_CTYPE_inline int
+__istype(__darwin_ct_rune_t _c, unsigned long _f)
+{
+#ifdef USE_ASCII
+ return !!(__maskrune(_c, _f));
+#else /* USE_ASCII */
+ return (isascii(_c) ? !!(_DefaultRuneLocale.__runetype[_c] & _f)
+ : !!__maskrune(_c, _f));
+#endif /* USE_ASCII */
+}
+
+__DARWIN_CTYPE_inline __darwin_ct_rune_t
+__isctype(__darwin_ct_rune_t _c, unsigned long _f)
+{
+#ifdef USE_ASCII
+ return !!(__maskrune(_c, _f));
+#else /* USE_ASCII */
+ return (_c < 0 || _c >= _CACHED_RUNES) ? 0 :
+ !!(_DefaultRuneLocale.__runetype[_c] & _f);
+#endif /* USE_ASCII */
+}
+
+#ifdef USE_ASCII
+__DARWIN_CTYPE_inline __darwin_ct_rune_t
+__toupper(__darwin_ct_rune_t _c)
+{
+ return _DefaultRuneLocale.__mapupper[_c & 0xff];
+}
+
+__DARWIN_CTYPE_inline __darwin_ct_rune_t
+__tolower(__darwin_ct_rune_t _c)
+{
+ return _DefaultRuneLocale.__maplower[_c & 0xff];
+}
+//Begin-Libc
+#elif defined(__LIBC__)
+/*
+ * We can't do what we do for __toupper_l() (check for ASCII first, then call
+ * ___toupper_l() otherwise) because versions of ___toupper() before Tiger
+ * assume c >= _CACHED_RUNES. So we are stuck making __toupper() a routine
+ * to hide the extended locale details, outside of Libc.
+ */
+__DARWIN_CTYPE_inline __darwin_ct_rune_t
+__toupper(__darwin_ct_rune_t _c)
+{
+ return (_c < 0 || _c >= _CACHED_RUNES) ? ___toupper(_c) :
+ __current_locale()->__lc_ctype->_CurrentRuneLocale.__mapupper[_c];
+}
+
+__DARWIN_CTYPE_inline __darwin_ct_rune_t
+__tolower(__darwin_ct_rune_t _c)
+{
+ return (_c < 0 || _c >= _CACHED_RUNES) ? ___tolower(_c) :
+ __current_locale()->__lc_ctype->_CurrentRuneLocale.__maplower[_c];
+}
+//End-Libc
+#else /* !USE_ASCII */
+__BEGIN_DECLS
+__darwin_ct_rune_t __toupper(__darwin_ct_rune_t);
+__darwin_ct_rune_t __tolower(__darwin_ct_rune_t);
+__END_DECLS
+#endif /* USE_ASCII */
+
+__DARWIN_CTYPE_inline int
+__wcwidth(__darwin_ct_rune_t _c)
+{
+ unsigned int _x;
+
+ if (_c == 0)
+ return (0);
+ _x = (unsigned int)__maskrune(_c, _CTYPE_SWM|_CTYPE_R);
+ if ((_x & _CTYPE_SWM) != 0)
+ return ((_x & _CTYPE_SWM) >> _CTYPE_SWS);
+ return ((_x & _CTYPE_R) != 0 ? 1 : -1);
+}
+
+#ifndef _EXTERNALIZE_CTYPE_INLINES_
+
+#define _tolower(c) __tolower(c)
+#define _toupper(c) __toupper(c)
+
+__DARWIN_CTYPE_TOP_inline int
+isalnum(int _c)
+{
+ return (__istype(_c, _CTYPE_A|_CTYPE_D));
+}
+
+__DARWIN_CTYPE_TOP_inline int
+isalpha(int _c)
+{
+ return (__istype(_c, _CTYPE_A));
+}
+
+__DARWIN_CTYPE_TOP_inline int
+isblank(int _c)
+{
+ return (__istype(_c, _CTYPE_B));
+}
+
+__DARWIN_CTYPE_TOP_inline int
+iscntrl(int _c)
+{
+ return (__istype(_c, _CTYPE_C));
+}
+
+/* ANSI -- locale independent */
+__DARWIN_CTYPE_TOP_inline int
+isdigit(int _c)
+{
+ return (__isctype(_c, _CTYPE_D));
+}
+
+__DARWIN_CTYPE_TOP_inline int
+isgraph(int _c)
+{
+ return (__istype(_c, _CTYPE_G));
+}
+
+__DARWIN_CTYPE_TOP_inline int
+islower(int _c)
+{
+ return (__istype(_c, _CTYPE_L));
+}
+
+__DARWIN_CTYPE_TOP_inline int
+isprint(int _c)
+{
+ return (__istype(_c, _CTYPE_R));
+}
+
+__DARWIN_CTYPE_TOP_inline int
+ispunct(int _c)
+{
+ return (__istype(_c, _CTYPE_P));
+}
+
+__DARWIN_CTYPE_TOP_inline int
+isspace(int _c)
+{
+ return (__istype(_c, _CTYPE_S));
+}
+
+__DARWIN_CTYPE_TOP_inline int
+isupper(int _c)
+{
+ return (__istype(_c, _CTYPE_U));
+}
+
+/* ANSI -- locale independent */
+__DARWIN_CTYPE_TOP_inline int
+isxdigit(int _c)
+{
+ return (__isctype(_c, _CTYPE_X));
+}
+
+__DARWIN_CTYPE_TOP_inline int
+toascii(int _c)
+{
+ return (_c & 0x7F);
+}
+
+__DARWIN_CTYPE_TOP_inline int
+tolower(int _c)
+{
+ return (__tolower(_c));
+}
+
+__DARWIN_CTYPE_TOP_inline int
+toupper(int _c)
+{
+ return (__toupper(_c));
+}
+
+#if !defined(_ANSI_SOURCE) && (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE))
+__DARWIN_CTYPE_TOP_inline int
+digittoint(int _c)
+{
+ return (__maskrune(_c, 0x0F));
+}
+
+__DARWIN_CTYPE_TOP_inline int
+ishexnumber(int _c)
+{
+ return (__istype(_c, _CTYPE_X));
+}
+
+__DARWIN_CTYPE_TOP_inline int
+isideogram(int _c)
+{
+ return (__istype(_c, _CTYPE_I));
+}
+
+__DARWIN_CTYPE_TOP_inline int
+isnumber(int _c)
+{
+ return (__istype(_c, _CTYPE_D));
+}
+
+__DARWIN_CTYPE_TOP_inline int
+isphonogram(int _c)
+{
+ return (__istype(_c, _CTYPE_Q));
+}
+
+__DARWIN_CTYPE_TOP_inline int
+isrune(int _c)
+{
+ return (__istype(_c, 0xFFFFFFF0L));
+}
+
+__DARWIN_CTYPE_TOP_inline int
+isspecial(int _c)
+{
+ return (__istype(_c, _CTYPE_T));
+}
+#endif /* !_ANSI_SOURCE && (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */
+#endif /* _EXTERNALIZE_CTYPE_INLINES_ */
+
+#else /* not using inlines */
+
+__BEGIN_DECLS
+int isalnum(int);
+int isalpha(int);
+int isblank(int);
+int iscntrl(int);
+int isdigit(int);
+int isgraph(int);
+int islower(int);
+int isprint(int);
+int ispunct(int);
+int isspace(int);
+int isupper(int);
+int isxdigit(int);
+int tolower(int);
+int toupper(int);
+int isascii(int);
+int toascii(int);
+
+#if !defined(_ANSI_SOURCE) && (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE))
+int _tolower(int);
+int _toupper(int);
+int digittoint(int);
+int ishexnumber(int);
+int isideogram(int);
+int isnumber(int);
+int isphonogram(int);
+int isrune(int);
+int isspecial(int);
+#endif
+__END_DECLS
+
+#endif /* using inlines */
+
+#ifdef _USE_EXTENDED_LOCALES_
+#include <xlocale/_ctype.h>
+#endif /* _USE_EXTENDED_LOCALES_ */
+
+#endif /* !_CTYPE_H_ */
--- /dev/null
+/*
+ * Copyright (c) 2000, 2011 Apple Inc. All rights reserved.
+ *
+ * @APPLE_LICENSE_HEADER_START@
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ *
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
+ *
+ * @APPLE_LICENSE_HEADER_END@
+ */
+/*
+ * Copyright (c) 2001-2009 Ville Laurikari <vl@iki.fi>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+/*-
+ * Copyright (c) 1992 Henry Spencer.
+ * Copyright (c) 1992, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Henry Spencer of the University of Toronto.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)regex.h 8.2 (Berkeley) 1/3/94
+ */
+
+/*
+ * Common header for regex.h and xlocale/_regex.h
+ */
+
+#ifndef __REGEX_H_
+#define __REGEX_H_
+
+#include <_types.h>
+#include <Availability.h>
+#include <sys/_types/_size_t.h>
+
+/*********/
+/* types */
+/*********/
+#if __DARWIN_C_LEVEL >= __DARWIN_C_FULL
+#include <sys/_types/_wchar_t.h>
+#endif /* __DARWIN_C_LEVEL >= __DARWIN_C_FULL */
+
+typedef __darwin_off_t regoff_t;
+
+typedef struct {
+ int re_magic;
+ size_t re_nsub; /* number of parenthesized subexpressions */
+ const char *re_endp; /* end pointer for REG_PEND */
+ struct re_guts *re_g; /* none of your business :-) */
+} regex_t;
+
+typedef struct {
+ regoff_t rm_so; /* start of match */
+ regoff_t rm_eo; /* end of match */
+} regmatch_t;
+
+#endif /* !__REGEX_H_ */
--- /dev/null
+/*
+ * Copyright (c) 2000, 2005, 2007, 2009, 2010 Apple Inc. All rights reserved.
+ *
+ * @APPLE_LICENSE_HEADER_START@
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ *
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
+ *
+ * @APPLE_LICENSE_HEADER_END@
+ */
+/*-
+ * Copyright (c) 1990, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)stdio.h 8.5 (Berkeley) 4/29/95
+ */
+
+/*
+ * Common header for stdio.h and xlocale/_stdio.h
+ */
+
+#ifndef __STDIO_H_
+#define __STDIO_H_
+
+#include <sys/cdefs.h>
+#include <Availability.h>
+
+#include <_types.h>
+
+/* DO NOT REMOVE THIS COMMENT: fixincludes needs to see:
+ * __gnuc_va_list and include <stdarg.h> */
+#include <sys/_types/_va_list.h>
+#include <sys/_types/_size_t.h>
+#include <sys/_types/_null.h>
+
+#include <sys/stdio.h>
+
+typedef __darwin_off_t fpos_t;
+
+#define _FSTDIO /* Define for new stdio with functions. */
+
+/*
+ * NB: to fit things in six character monocase externals, the stdio
+ * code uses the prefix `__s' for stdio objects, typically followed
+ * by a three-character attempt at a mnemonic.
+ */
+
+/* stdio buffers */
+struct __sbuf {
+ unsigned char *_base;
+ int _size;
+};
+
+/* hold a buncha junk that would grow the ABI */
+struct __sFILEX;
+
+/*
+ * stdio state variables.
+ *
+ * The following always hold:
+ *
+ * if (_flags&(__SLBF|__SWR)) == (__SLBF|__SWR),
+ * _lbfsize is -_bf._size, else _lbfsize is 0
+ * if _flags&__SRD, _w is 0
+ * if _flags&__SWR, _r is 0
+ *
+ * This ensures that the getc and putc macros (or inline functions) never
+ * try to write or read from a file that is in `read' or `write' mode.
+ * (Moreover, they can, and do, automatically switch from read mode to
+ * write mode, and back, on "r+" and "w+" files.)
+ *
+ * _lbfsize is used only to make the inline line-buffered output stream
+ * code as compact as possible.
+ *
+ * _ub, _up, and _ur are used when ungetc() pushes back more characters
+ * than fit in the current _bf, or when ungetc() pushes back a character
+ * that does not match the previous one in _bf. When this happens,
+ * _ub._base becomes non-nil (i.e., a stream has ungetc() data iff
+ * _ub._base!=NULL) and _up and _ur save the current values of _p and _r.
+ *
+ * NB: see WARNING above before changing the layout of this structure!
+ */
+typedef struct __sFILE {
+ unsigned char *_p; /* current position in (some) buffer */
+ int _r; /* read space left for getc() */
+ int _w; /* write space left for putc() */
+ short _flags; /* flags, below; this FILE is free if 0 */
+ short _file; /* fileno, if Unix descriptor, else -1 */
+ struct __sbuf _bf; /* the buffer (at least 1 byte, if !NULL) */
+ int _lbfsize; /* 0 or -_bf._size, for inline putc */
+
+ /* operations */
+ void *_cookie; /* cookie passed to io functions */
+ int (* _Nullable _close)(void *);
+ int (* _Nullable _read) (void *, char *, int);
+ fpos_t (* _Nullable _seek) (void *, fpos_t, int);
+ int (* _Nullable _write)(void *, const char *, int);
+
+ /* separate buffer for long sequences of ungetc() */
+ struct __sbuf _ub; /* ungetc buffer */
+ struct __sFILEX *_extra; /* additions to FILE to not break ABI */
+ int _ur; /* saved _r when _r is counting ungetc data */
+
+ /* tricks to meet minimum requirements even when malloc() fails */
+ unsigned char _ubuf[3]; /* guarantee an ungetc() buffer */
+ unsigned char _nbuf[1]; /* guarantee a getc() buffer */
+
+ /* separate buffer for fgetln() when line crosses buffer boundary */
+ struct __sbuf _lb; /* buffer for fgetln() */
+
+ /* Unix stdio files get aligned to block boundaries on fseek() */
+ int _blksize; /* stat.st_blksize (may be != _bf._size) */
+ fpos_t _offset; /* current lseek offset (see WARNING) */
+} FILE;
+
+#endif /* __STDIO_H_ */
#ifndef __WCTYPE_H_
#define __WCTYPE_H_
-#include <sys/cdefs.h>
-#include <_types.h>
-
-#include <sys/_types/_wint_t.h>
-#include <sys/_types/_wint_t.h>
-#include <_types/_wctype_t.h>
-
-#ifndef WEOF
-#define WEOF __DARWIN_WEOF
-#endif
-
-#ifndef __DARWIN_WCTYPE_TOP_inline
-#define __DARWIN_WCTYPE_TOP_inline __header_inline
-#endif
-
-#include <ctype.h>
+#include <__wctype.h>
/*
* Use inline functions if we are allowed to and the compiler supports them.
#include <sys/cdefs.h>
+struct _xlocale; /* forward reference */
+typedef struct _xlocale * locale_t;
+
__BEGIN_DECLS
int ___mb_cur_max(void);
int ___mb_cur_max_l(locale_t);
* @(#)ctype.h 8.4 (Berkeley) 1/21/94
*/
-//Begin-Libc
-#include "xlocale_private.h"
-//End-Libc
#ifndef _CTYPE_H_
#define _CTYPE_H_
-#include <sys/cdefs.h>
-#include <runetype.h>
-
-#define _CTYPE_A 0x00000100L /* Alpha */
-#define _CTYPE_C 0x00000200L /* Control */
-#define _CTYPE_D 0x00000400L /* Digit */
-#define _CTYPE_G 0x00000800L /* Graph */
-#define _CTYPE_L 0x00001000L /* Lower */
-#define _CTYPE_P 0x00002000L /* Punct */
-#define _CTYPE_S 0x00004000L /* Space */
-#define _CTYPE_U 0x00008000L /* Upper */
-#define _CTYPE_X 0x00010000L /* X digit */
-#define _CTYPE_B 0x00020000L /* Blank */
-#define _CTYPE_R 0x00040000L /* Print */
-#define _CTYPE_I 0x00080000L /* Ideogram */
-#define _CTYPE_T 0x00100000L /* Special */
-#define _CTYPE_Q 0x00200000L /* Phonogram */
-#define _CTYPE_SW0 0x20000000L /* 0 width character */
-#define _CTYPE_SW1 0x40000000L /* 1 width character */
-#define _CTYPE_SW2 0x80000000L /* 2 width character */
-#define _CTYPE_SW3 0xc0000000L /* 3 width character */
-#define _CTYPE_SWM 0xe0000000L /* Mask for screen width data */
-#define _CTYPE_SWS 30 /* Bits to shift to get width */
-
-#ifdef _NONSTD_SOURCE
-/*
- * Backward compatibility
- */
-#define _A _CTYPE_A /* Alpha */
-#define _C _CTYPE_C /* Control */
-#define _D _CTYPE_D /* Digit */
-#define _G _CTYPE_G /* Graph */
-#define _L _CTYPE_L /* Lower */
-#define _P _CTYPE_P /* Punct */
-#define _S _CTYPE_S /* Space */
-#define _U _CTYPE_U /* Upper */
-#define _X _CTYPE_X /* X digit */
-#define _B _CTYPE_B /* Blank */
-#define _R _CTYPE_R /* Print */
-#define _I _CTYPE_I /* Ideogram */
-#define _T _CTYPE_T /* Special */
-#define _Q _CTYPE_Q /* Phonogram */
-#define _SW0 _CTYPE_SW0 /* 0 width character */
-#define _SW1 _CTYPE_SW1 /* 1 width character */
-#define _SW2 _CTYPE_SW2 /* 2 width character */
-#define _SW3 _CTYPE_SW3 /* 3 width character */
-#endif /* _NONSTD_SOURCE */
-
-//Begin-Libc
-/*
- * _EXTERNALIZE_CTYPE_INLINES_ is defined in locale/nomacros.c to tell us
- * to generate code for extern versions of all intermediate inline functions.
- */
-#ifdef _EXTERNALIZE_CTYPE_INLINES_
-#define _USE_CTYPE_INLINE_
-#define __DARWIN_CTYPE_inline
-#else /* !_EXTERNALIZE_CTYPE_INLINES_ */
-//End-Libc
-#define __DARWIN_CTYPE_inline __header_inline
-//Begin-Libc
-#endif /* !_EXTERNALIZE_CTYPE_INLINES_ */
-//End-Libc
-
-//Begin-Libc
-/*
- * _EXTERNALIZE_CTYPE_INLINES_TOP_ is defined in locale/isctype.c to tell us
- * to generate code for extern versions of all top-level inline functions.
- */
-#ifdef _EXTERNALIZE_CTYPE_INLINES_TOP_
-#define _USE_CTYPE_INLINE_
-#define __DARWIN_CTYPE_TOP_inline
-#else /* !_EXTERNALIZE_CTYPE_INLINES_TOP_ */
-//End-Libc
-#define __DARWIN_CTYPE_TOP_inline __header_inline
-//Begin-Libc
-#endif /* _EXTERNALIZE_CTYPE_INLINES_TOP_ */
-//End-Libc
-
-/*
- * Use inline functions if we are allowed to and the compiler supports them.
- */
-#if !defined(_DONT_USE_CTYPE_INLINE_) && \
- (defined(_USE_CTYPE_INLINE_) || defined(__GNUC__) || defined(__cplusplus))
-
-/* See comments in <machine/_type.h> about __darwin_ct_rune_t. */
-__BEGIN_DECLS
-unsigned long ___runetype(__darwin_ct_rune_t);
-__darwin_ct_rune_t ___tolower(__darwin_ct_rune_t);
-__darwin_ct_rune_t ___toupper(__darwin_ct_rune_t);
-__END_DECLS
-
-__DARWIN_CTYPE_TOP_inline int
-isascii(int _c)
-{
- return ((_c & ~0x7F) == 0);
-}
-
-#ifdef USE_ASCII
-__DARWIN_CTYPE_inline int
-__maskrune(__darwin_ct_rune_t _c, unsigned long _f)
-{
- return (int)_DefaultRuneLocale.__runetype[_c & 0xff] & (__uint32_t)_f;
-}
-//Begin-Libc
-#elif defined(__LIBC__)
-__DARWIN_CTYPE_inline int
-__maskrune(__darwin_ct_rune_t _c, unsigned long _f)
-{
- /* _CurrentRuneLocale.__runetype[_c] is __uint32_t
- * _f is unsigned long
- * ___runetype(_c) is unsigned long
- * retval is int
- */
- return (int)((_c < 0 || _c >= _CACHED_RUNES) ? (__uint32_t)___runetype(_c) :
- __current_locale()->__lc_ctype->_CurrentRuneLocale.__runetype[_c]) & (__uint32_t)_f;
-}
-//End-Libc
-#else /* !USE_ASCII */
-__BEGIN_DECLS
-int __maskrune(__darwin_ct_rune_t, unsigned long);
-__END_DECLS
-#endif /* USE_ASCII */
-
-__DARWIN_CTYPE_inline int
-__istype(__darwin_ct_rune_t _c, unsigned long _f)
-{
-#ifdef USE_ASCII
- return !!(__maskrune(_c, _f));
-#else /* USE_ASCII */
- return (isascii(_c) ? !!(_DefaultRuneLocale.__runetype[_c] & _f)
- : !!__maskrune(_c, _f));
-#endif /* USE_ASCII */
-}
-
-__DARWIN_CTYPE_inline __darwin_ct_rune_t
-__isctype(__darwin_ct_rune_t _c, unsigned long _f)
-{
-#ifdef USE_ASCII
- return !!(__maskrune(_c, _f));
-#else /* USE_ASCII */
- return (_c < 0 || _c >= _CACHED_RUNES) ? 0 :
- !!(_DefaultRuneLocale.__runetype[_c] & _f);
-#endif /* USE_ASCII */
-}
-
-#ifdef USE_ASCII
-__DARWIN_CTYPE_inline __darwin_ct_rune_t
-__toupper(__darwin_ct_rune_t _c)
-{
- return _DefaultRuneLocale.__mapupper[_c & 0xff];
-}
-
-__DARWIN_CTYPE_inline __darwin_ct_rune_t
-__tolower(__darwin_ct_rune_t _c)
-{
- return _DefaultRuneLocale.__maplower[_c & 0xff];
-}
-//Begin-Libc
-#elif defined(__LIBC__)
-/*
- * We can't do what we do for __toupper_l() (check for ASCII first, then call
- * ___toupper_l() otherwise) because versions of ___toupper() before Tiger
- * assume c >= _CACHED_RUNES. So we are stuck making __toupper() a routine
- * to hide the extended locale details, outside of Libc.
- */
-__DARWIN_CTYPE_inline __darwin_ct_rune_t
-__toupper(__darwin_ct_rune_t _c)
-{
- return (_c < 0 || _c >= _CACHED_RUNES) ? ___toupper(_c) :
- __current_locale()->__lc_ctype->_CurrentRuneLocale.__mapupper[_c];
-}
-
-__DARWIN_CTYPE_inline __darwin_ct_rune_t
-__tolower(__darwin_ct_rune_t _c)
-{
- return (_c < 0 || _c >= _CACHED_RUNES) ? ___tolower(_c) :
- __current_locale()->__lc_ctype->_CurrentRuneLocale.__maplower[_c];
-}
-//End-Libc
-#else /* !USE_ASCII */
-__BEGIN_DECLS
-__darwin_ct_rune_t __toupper(__darwin_ct_rune_t);
-__darwin_ct_rune_t __tolower(__darwin_ct_rune_t);
-__END_DECLS
-#endif /* USE_ASCII */
-
-__DARWIN_CTYPE_inline int
-__wcwidth(__darwin_ct_rune_t _c)
-{
- unsigned int _x;
-
- if (_c == 0)
- return (0);
- _x = (unsigned int)__maskrune(_c, _CTYPE_SWM|_CTYPE_R);
- if ((_x & _CTYPE_SWM) != 0)
- return ((_x & _CTYPE_SWM) >> _CTYPE_SWS);
- return ((_x & _CTYPE_R) != 0 ? 1 : -1);
-}
-
-#ifndef _EXTERNALIZE_CTYPE_INLINES_
-
-#define _tolower(c) __tolower(c)
-#define _toupper(c) __toupper(c)
-
-__DARWIN_CTYPE_TOP_inline int
-isalnum(int _c)
-{
- return (__istype(_c, _CTYPE_A|_CTYPE_D));
-}
-
-__DARWIN_CTYPE_TOP_inline int
-isalpha(int _c)
-{
- return (__istype(_c, _CTYPE_A));
-}
-
-__DARWIN_CTYPE_TOP_inline int
-isblank(int _c)
-{
- return (__istype(_c, _CTYPE_B));
-}
-
-__DARWIN_CTYPE_TOP_inline int
-iscntrl(int _c)
-{
- return (__istype(_c, _CTYPE_C));
-}
-
-/* ANSI -- locale independent */
-__DARWIN_CTYPE_TOP_inline int
-isdigit(int _c)
-{
- return (__isctype(_c, _CTYPE_D));
-}
-
-__DARWIN_CTYPE_TOP_inline int
-isgraph(int _c)
-{
- return (__istype(_c, _CTYPE_G));
-}
-
-__DARWIN_CTYPE_TOP_inline int
-islower(int _c)
-{
- return (__istype(_c, _CTYPE_L));
-}
-
-__DARWIN_CTYPE_TOP_inline int
-isprint(int _c)
-{
- return (__istype(_c, _CTYPE_R));
-}
-
-__DARWIN_CTYPE_TOP_inline int
-ispunct(int _c)
-{
- return (__istype(_c, _CTYPE_P));
-}
-
-__DARWIN_CTYPE_TOP_inline int
-isspace(int _c)
-{
- return (__istype(_c, _CTYPE_S));
-}
-
-__DARWIN_CTYPE_TOP_inline int
-isupper(int _c)
-{
- return (__istype(_c, _CTYPE_U));
-}
-
-/* ANSI -- locale independent */
-__DARWIN_CTYPE_TOP_inline int
-isxdigit(int _c)
-{
- return (__isctype(_c, _CTYPE_X));
-}
-
-__DARWIN_CTYPE_TOP_inline int
-toascii(int _c)
-{
- return (_c & 0x7F);
-}
-
-__DARWIN_CTYPE_TOP_inline int
-tolower(int _c)
-{
- return (__tolower(_c));
-}
-
-__DARWIN_CTYPE_TOP_inline int
-toupper(int _c)
-{
- return (__toupper(_c));
-}
-
-#if !defined(_ANSI_SOURCE) && (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE))
-__DARWIN_CTYPE_TOP_inline int
-digittoint(int _c)
-{
- return (__maskrune(_c, 0x0F));
-}
-
-__DARWIN_CTYPE_TOP_inline int
-ishexnumber(int _c)
-{
- return (__istype(_c, _CTYPE_X));
-}
-
-__DARWIN_CTYPE_TOP_inline int
-isideogram(int _c)
-{
- return (__istype(_c, _CTYPE_I));
-}
-
-__DARWIN_CTYPE_TOP_inline int
-isnumber(int _c)
-{
- return (__istype(_c, _CTYPE_D));
-}
-
-__DARWIN_CTYPE_TOP_inline int
-isphonogram(int _c)
-{
- return (__istype(_c, _CTYPE_Q));
-}
-
-__DARWIN_CTYPE_TOP_inline int
-isrune(int _c)
-{
- return (__istype(_c, 0xFFFFFFF0L));
-}
-
-__DARWIN_CTYPE_TOP_inline int
-isspecial(int _c)
-{
- return (__istype(_c, _CTYPE_T));
-}
-#endif /* !_ANSI_SOURCE && (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */
-#endif /* _EXTERNALIZE_CTYPE_INLINES_ */
-
-#else /* not using inlines */
-
-__BEGIN_DECLS
-int isalnum(int);
-int isalpha(int);
-int isblank(int);
-int iscntrl(int);
-int isdigit(int);
-int isgraph(int);
-int islower(int);
-int isprint(int);
-int ispunct(int);
-int isspace(int);
-int isupper(int);
-int isxdigit(int);
-int tolower(int);
-int toupper(int);
-int isascii(int);
-int toascii(int);
-
-#if !defined(_ANSI_SOURCE) && (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE))
-int _tolower(int);
-int _toupper(int);
-int digittoint(int);
-int ishexnumber(int);
-int isideogram(int);
-int isnumber(int);
-int isphonogram(int);
-int isrune(int);
-int isspecial(int);
-#endif
-__END_DECLS
-
-#endif /* using inlines */
+#include <_ctype.h>
#ifdef _USE_EXTENDED_LOCALES_
#include <xlocale/_ctype.h>
#ifndef _REGEX_H_
#define _REGEX_H_
-#include <_types.h>
-#include <Availability.h>
-#include <sys/_types/_size_t.h>
-
-/*********/
-/* types */
-/*********/
-#if __DARWIN_C_LEVEL >= __DARWIN_C_FULL
-#include <sys/_types/_wchar_t.h>
-#endif /* __DARWIN_C_LEVEL >= __DARWIN_C_FULL */
-
-typedef __darwin_off_t regoff_t;
-
-typedef struct {
- int re_magic;
- size_t re_nsub; /* number of parenthesized subexpressions */
- const char *re_endp; /* end pointer for REG_PEND */
- struct re_guts *re_g; /* none of your business :-) */
-} regex_t;
-
-typedef struct {
- regoff_t rm_so; /* start of match */
- regoff_t rm_eo; /* end of match */
-} regmatch_t;
+#include <_regex.h>
/*******************/
/* regcomp() flags */
#ifndef _STDIO_H_
#define _STDIO_H_
-#include <sys/cdefs.h>
-#include <Availability.h>
-
-#include <_types.h>
-
-/* DO NOT REMOVE THIS COMMENT: fixincludes needs to see:
- * __gnuc_va_list and include <stdarg.h> */
-#include <sys/_types/_va_list.h>
-#include <sys/_types/_size_t.h>
-#include <sys/_types/_null.h>
-
-#include <sys/stdio.h>
-
-typedef __darwin_off_t fpos_t;
-
-#define _FSTDIO /* Define for new stdio with functions. */
-
-/*
- * NB: to fit things in six character monocase externals, the stdio
- * code uses the prefix `__s' for stdio objects, typically followed
- * by a three-character attempt at a mnemonic.
- */
-
-/* stdio buffers */
-struct __sbuf {
- unsigned char *_base;
- int _size;
-};
-
-/* hold a buncha junk that would grow the ABI */
-struct __sFILEX;
-
-/*
- * stdio state variables.
- *
- * The following always hold:
- *
- * if (_flags&(__SLBF|__SWR)) == (__SLBF|__SWR),
- * _lbfsize is -_bf._size, else _lbfsize is 0
- * if _flags&__SRD, _w is 0
- * if _flags&__SWR, _r is 0
- *
- * This ensures that the getc and putc macros (or inline functions) never
- * try to write or read from a file that is in `read' or `write' mode.
- * (Moreover, they can, and do, automatically switch from read mode to
- * write mode, and back, on "r+" and "w+" files.)
- *
- * _lbfsize is used only to make the inline line-buffered output stream
- * code as compact as possible.
- *
- * _ub, _up, and _ur are used when ungetc() pushes back more characters
- * than fit in the current _bf, or when ungetc() pushes back a character
- * that does not match the previous one in _bf. When this happens,
- * _ub._base becomes non-nil (i.e., a stream has ungetc() data iff
- * _ub._base!=NULL) and _up and _ur save the current values of _p and _r.
- *
- * NB: see WARNING above before changing the layout of this structure!
- */
-typedef struct __sFILE {
- unsigned char *_p; /* current position in (some) buffer */
- int _r; /* read space left for getc() */
- int _w; /* write space left for putc() */
- short _flags; /* flags, below; this FILE is free if 0 */
- short _file; /* fileno, if Unix descriptor, else -1 */
- struct __sbuf _bf; /* the buffer (at least 1 byte, if !NULL) */
- int _lbfsize; /* 0 or -_bf._size, for inline putc */
-
- /* operations */
- void *_cookie; /* cookie passed to io functions */
- int (* _Nullable _close)(void *);
- int (* _Nullable _read) (void *, char *, int);
- fpos_t (* _Nullable _seek) (void *, fpos_t, int);
- int (* _Nullable _write)(void *, const char *, int);
-
- /* separate buffer for long sequences of ungetc() */
- struct __sbuf _ub; /* ungetc buffer */
- struct __sFILEX *_extra; /* additions to FILE to not break ABI */
- int _ur; /* saved _r when _r is counting ungetc data */
-
- /* tricks to meet minimum requirements even when malloc() fails */
- unsigned char _ubuf[3]; /* guarantee an ungetc() buffer */
- unsigned char _nbuf[1]; /* guarantee a getc() buffer */
-
- /* separate buffer for fgetln() when line crosses buffer boundary */
- struct __sbuf _lb; /* buffer for fgetln() */
-
- /* Unix stdio files get aligned to block boundaries on fseek() */
- int _blksize; /* stat.st_blksize (may be != _bf._size) */
- fpos_t _offset; /* current lseek offset (see WARNING) */
-} FILE;
+#include <_stdio.h>
__BEGIN_DECLS
extern FILE *__stdinp;
long nrand48(unsigned short[3]) __swift_unavailable("Use arc4random instead.");
int posix_openpt(int);
char *ptsname(int);
+
+#if (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE))
+int ptsname_r(int fildes, char *buffer, size_t buflen) __API_AVAILABLE(macos(10.13.4), ios(11.3), tvos(11.3), watchos(4.3));
+#endif
+
//Begin-Libc
#ifndef LIBC_ALIAS_PUTENV
//End-Libc
#define _USE_EXTENDED_LOCALES_
#endif /* _USE_EXTENDED_LOCALES_ */
-struct _xlocale; /* forward reference */
-typedef struct _xlocale * locale_t;
-
#include <_locale.h>
#include <_xlocale.h>
#ifndef _XLOCALE___WCTYPE_H_
#define _XLOCALE___WCTYPE_H_
+#include <__wctype.h>
+#include <xlocale/_ctype.h>
+
#if !defined(_DONT_USE_CTYPE_INLINE_) && \
(defined(_USE_CTYPE_INLINE_) || defined(__GNUC__) || defined(__cplusplus))
#ifndef _XLOCALE__CTYPE_H_
#define _XLOCALE__CTYPE_H_
+#include <_ctype.h>
+#include <_xlocale.h>
+
/*
* Use inline functions if we are allowed to and the compiler supports them.
*/
#ifndef _XLOCALE__INTTYPES_H_
#define _XLOCALE__INTTYPES_H_
+#include <sys/cdefs.h>
+#include <stdint.h>
+#include <_xlocale.h>
+
__BEGIN_DECLS
intmax_t strtoimax_l(const char * __restrict nptr, char ** __restrict endptr,
int base, locale_t);
#ifndef _XLOCALE__LANGINFO_H_
#define _XLOCALE__LANGINFO_H_
+#include <sys/cdefs.h>
+#include <_types/_nl_item.h>
+#include <_xlocale.h>
+
__BEGIN_DECLS
char *nl_langinfo_l(nl_item, locale_t);
__END_DECLS
#ifndef _XLOCALE__MONETARY_H_
#define _XLOCALE__MONETARY_H_
+#include <sys/cdefs.h>
+#include <_types.h>
+#include <sys/_types/_size_t.h>
+#include <sys/_types/_ssize_t.h>
+#include <_xlocale.h>
+
__BEGIN_DECLS
ssize_t strfmon_l(char *, size_t, locale_t, const char *, ...)
__strfmonlike(4, 5);
#ifndef _XLOCALE__REGEX_H_
#define _XLOCALE__REGEX_H_
+#ifndef _REGEX_H_
+#include <_regex.h>
+#endif // _REGEX_H_
+#include <_xlocale.h>
+
__BEGIN_DECLS
int regcomp_l(regex_t * __restrict, const char * __restrict, int,
#ifndef _XLOCALE__STDIO_H_
#define _XLOCALE__STDIO_H_
+#include <_stdio.h>
+#include <_xlocale.h>
+
__BEGIN_DECLS
int fprintf_l(FILE * __restrict, locale_t __restrict, const char * __restrict, ...)
#ifndef _XLOCALE__STDLIB_H_
#define _XLOCALE__STDLIB_H_
+#include <sys/cdefs.h>
+#include <sys/_types/_size_t.h>
+#include <sys/_types/_wchar_t.h>
+#include <_xlocale.h>
+
__BEGIN_DECLS
double atof_l(const char *, locale_t);
int atoi_l(const char *, locale_t);
#ifndef _XLOCALE__STRING_H_
#define _XLOCALE__STRING_H_
+#include <sys/cdefs.h>
+#include <sys/_types/_size_t.h>
+#include <_xlocale.h>
+
__BEGIN_DECLS
int strcoll_l(const char *, const char *, locale_t);
size_t strxfrm_l(char *, const char *, size_t, locale_t);
#ifndef _XLOCALE__TIME_H_
#define _XLOCALE__TIME_H_
+#include <sys/cdefs.h>
+#include <sys/_types/_size_t.h>
+#include <_types.h>
+#include <_xlocale.h>
+
__BEGIN_DECLS
//Begin-Libc
#ifndef LIBC_ALIAS_STRFTIME_L
#ifndef _XLOCALE__WCHAR_H_
#define _XLOCALE__WCHAR_H_
+#include <_stdio.h>
+#include <_xlocale.h>
+
/* Initially added in Issue 4 */
__BEGIN_DECLS
wint_t btowc_l(int, locale_t);
#ifndef _XLOCALE__WCTYPE_H_
#define _XLOCALE__WCTYPE_H_
+#include <__wctype.h>
+#include <_types/_wctrans_t.h>
+#include <xlocale/_ctype.h>
+
#if !defined(_DONT_USE_CTYPE_INLINE_) && \
(defined(_USE_CTYPE_INLINE_) || defined(__GNUC__) || defined(__cplusplus))
towlower.3 towlower.3 towlower_l.3
towupper.3 towupper.3 towupper_l.3
tsearch.3 tsearch.3 tdelete.3 tfind.3 twalk.3
-ttyname.3 ttyname.3 isatty.3 ttyslot.3
+ttyname.3 ttyname.3 ttyname_r.3 isatty.3 ttyslot.3
tzset.3 tzset.3 tzsetwall.3
ualarm.3 ualarm.3
ulimit.3 ulimit.3
* SUCH DAMAGE.
*/
+#define OS_CRASH_ENABLE_EXPERIMENTAL_LIBTRACE 1
+
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)vfprintf.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */
static_format_checked = __printf_is_memory_read_only((void*)fmt0, strlen(fmt0));
}
if (!static_format_checked) {
- os_crash("%n used in a non-immutable format string");
+ os_crash("%%n used in a non-immutable format string: %s", fmt0);
}
#endif // ALLOW_DYNAMIC_PERCENT_N
.Nm grantpt ,
.Nm posix_openpt ,
.Nm ptsname ,
+.Nm ptsname_r ,
.Nm unlockpt
.Nd pseudo-terminal access functions
.Sh SYNOPSIS
.Fo ptsname
.Fa "int fildes"
.Fc
+.Ft "int"
+.Fo ptsname_r
+.Fa "int fildes"
+.Fa "char *buffer"
+.Fa "size_t buflen"
+.Fc
.Ft int
.Fo unlockpt
.Fa "int fildes"
The
.Fn grantpt ,
.Fn ptsname ,
+.Fn ptsname_r ,
.Fn unlockpt ,
and
.Fn posix_openpt
functions allow access to pseudo-terminal devices.
-The first three functions accept a file descriptor
+The first four functions accept a file descriptor
that references the master half of a pseudo-terminal pair.
This file descriptor is created with
.Fn posix_openpt .
.Pp
The
.Fn ptsname
-function returns the full pathname of the slave device
+and
+.Fn ptsname_r
+functions return the full pathname of the slave device
counterpart to the master device specified with
.Fa fildes .
This value can be used
.Fn posix_openpt
and
.Fn grantpt
-have been called.
+have been called. The
+.Fn ptsname
+function is not guaranteed to be reentrant or thread safe. The
+.Fn ptsname_r
+function takes a buffer and length as arguments to avoid this problem.
.Pp
The
.Fn unlockpt
is set to indicate the error.
.Pp
The
+.Fn ptsname_r
+function returns 0 if successful. On failure, it returns -1 and the global variable
+.Va errno
+is set to indicate the error.
+.Pp
+The
.Fn posix_openpt
function returns a file descriptor to the first
available master pseudo-terminal device on success;
The
.Fn grantpt ,
.Fn ptsname ,
+.Fn ptsname_r ,
and
.Fn unlockpt
functions may fail and set
.El
.Pp
In addition, the
+.Fn ptsname_r
+function may set
+.Va errno
+to:
+.Bl -tag -width Er
+.It Bq Er EINVAL
+The
+.Va buffer
+argument is NULL.
+.El
+.Bl -tag -width Er
+.It Bq Er ERANGE
+The
+.Va bufsize
+argument is smaller than the length of the string to be returned.
+.El
+.Pp
+In addition, the
.Fn grantpt
function may set
.Va errno
The
.Fn grantpt ,
.Fn ptsname ,
+.Fn ptsname_r ,
and
.Fn unlockpt
functions may also fail and set
* @APPLE_LICENSE_HEADER_END@
*/
+#include <os/assumes.h>
+#include <os/once_private.h>
+#include <pthread.h>
#include <stdlib.h>
+#include <string.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <fcntl.h>
return ioctl(fd, TIOCPTYGRANT);
}
+// defined by TIOCPTYGNAME
+#define PTSNAME_MAX_SIZE 128
+
+static pthread_key_t ptsname_buffer_specific_key;
+static os_once_t ptsname_once;
+
+static void
+ptsname_once_init(void *ctx __unused)
+{
+ int ret = pthread_key_create(&ptsname_buffer_specific_key, free);
+ os_assert_zero(ret);
+}
+
/*
* ptsname call for cloning pty implementation.
*
char *
ptsname(int fd)
{
- static char *ptsnamebuf = NULL;
+ os_once(&ptsname_once, NULL, ptsname_once_init);
+ char *ptsnamebuf = pthread_getspecific(ptsname_buffer_specific_key);
+
+ if (ptsnamebuf == NULL) {
+ ptsnamebuf = malloc(PTSNAME_MAX_SIZE);
+ os_assert(ptsnamebuf);
+
+ int error = pthread_setspecific(ptsname_buffer_specific_key, ptsnamebuf);
+ os_assert_zero(error);
+ }
+
+ int error = ptsname_r(fd, ptsnamebuf, PTSNAME_MAX_SIZE);
+
+ return error ? NULL : ptsnamebuf;
+}
+
+int
+ptsname_r(int fd, char *buffer, size_t buflen)
+{
int error;
- char *retval = NULL;
struct stat sbuf;
+ char ptsnamebuf[PTSNAME_MAX_SIZE];
- if (ptsnamebuf == NULL) {
- ptsnamebuf = malloc(128); // defined by TIOCPTYGNAME
+ if (!buffer) {
+ errno = EINVAL;
+ return -1;
}
-
+
error = ioctl(fd, TIOCPTYGNAME, ptsnamebuf);
- if (!error) {
- /*
- * XXX TSD
- *
- * POSIX: Handle device rename test case, which is expected
- * to fail if the pty has been renamed.
- */
- if (stat(ptsnamebuf, &sbuf) == 0) {
- retval = ptsnamebuf;
- }
+ if (error) {
+ return -1;
}
- return (retval);
+ /*
+ * XXX TSD
+ *
+ * POSIX: Handle device rename test case, which is expected
+ * to fail if the pty has been renamed.
+ */
+ error = stat(ptsnamebuf, &sbuf);
+ if (error) {
+ return -1;
+ }
+
+ size_t len = strlen(ptsnamebuf) + 1;
+ if (buflen < len) {
+ errno = ERANGE;
+ return -1;
+ }
+
+ memcpy(buffer, ptsnamebuf, len);
+
+ return 0;
}
/*
siglongjmp(jbuf, 0);
}
-T_DECL(nxheap, "Non-executable heap", T_META_CHECK_LEAKS(NO))
+T_DECL(nxheap, "Non-executable heap", T_META_CHECK_LEAKS(false), T_META_ASROOT(true))
{
struct sigaction sa = {
.__sigaction_u.__sa_sigaction = action,
};
T_ASSERT_POSIX_ZERO(sigaction(SIGBUS, &sa, NULL), NULL);
-
+
if (sigsetjmp(jbuf, 0)) {
T_PASS("SIGBUS");
T_END;
struct winsize *winp;
{
int master, slave;
- char *sname;
+ char sname[128];
if ((master = posix_openpt(O_RDWR|O_NOCTTY)) < 0)
return -1;
if (grantpt(master) < 0 || unlockpt(master) < 0
- || (sname = ptsname(master)) == NULL
+ || ptsname_r(master, sname, sizeof(sname)) == -1
|| (slave = open(sname, O_RDWR|O_NOCTTY, 0)) < 0) {
(void) close(master);
return -1;
)
INC_INSTHDRS=(
+ __wctype.h
+ _ctype.h
_locale.h
+ _regex.h
+ _stdio.h
_types.h
_wctype.h
_xlocale.h
LIBPLATFORM_LDFLAGS = -lsystem$(SIM_SUFFIX)_platform
LIBPTHREAD_LDFLAGS = -lsystem$(SIM_SUFFIX)_pthread
LIBSYSCALL_LDFLAGS = -lsystem$(SIM_SUFFIX)_kernel
-LIBM_LDFLAGS = -lsystem$(SIM_SUFFIX)_m
+LIBM_LDFLAGS = -lsystem_m
LIBDYLD_LDFLAGS = -ldyld
LIBSYSTEM_C_LDFLAGS = -all_load -nostdlib -L/usr/lib/system -umbrella System $(CR_LDFLAGS) $(LIBCOMPILER_RT_LDFLAGS) $(LIBDYLD_LDFLAGS) $(LIBSYSCALL_LDFLAGS) $(LIBM_LDFLAGS) $(LIBMALLOC_LDFLAGS) $(LIBPLATFORM_LDFLAGS) $(LIBPTHREAD_LDFLAGS) $(UPWARD_LDFLAGS) $(LIBSYSTEM_C_EXTRA_LDFLAGS_$(CURRENT_ARCH)) -Wl,-interposable_list,$(DERIVED_FILES_DIR)/interposable.list -Wl,-unexported_symbols_list,$(DERIVED_FILES_DIR)/unexport.list -Wl,-alias_list,$(SRCROOT)/xcodescripts/alias.list -Wl,-order_file,$(SRCROOT)/xcodescripts/Libc.order -Wl,-sectalign,__DATA,__data,1000 @$(BUILT_PRODUCTS_DIR)/$(CURRENT_VARIANT).linklist
LIBSYSTEM_C_EXTRA_LDFLAGS_i386 = -Wl,-alias_list,$(SRCROOT)/xcodescripts/legacy_alias.list
// TODO: Remove upward links - mostly <rdar://problem/13183469>, macho is for assumes.c
-UPWARD_LDFLAGS = -Wl,-upward-ldispatch -Wl,-upward-llaunch -Wl,-upward-lmacho -Wl,-upward-lsystem_asl -Wl,-upward-lsystem_blocks -Wl,-upward-lsystem_info -Wl,-upward-lsystem_notify -Wl,-upward-lxpc -Wl,-upward-lcorecrypto
-UPWARD_LDFLAGS[sdk=*simulator*] = -Wl,-upward-ldispatch -Wl,-upward-lmacho_sim -Wl,-upward-lsystem_asl -Wl,-upward-lsystem_sim_blocks -Wl,-upward-lsystem_sim_info -Wl,-upward-lsystem_notify -Wl,-upward-lxpc -Wl,-upward-lcorecrypto
+UPWARD_LDFLAGS = -Wl,-upward-ldispatch -Wl,-upward-lmacho -Wl,-upward-lsystem_asl -Wl,-upward-lsystem_blocks -Wl,-upward-lsystem_info -Wl,-upward-lsystem_notify -Wl,-upward-lxpc -Wl,-upward-lcorecrypto -Wl,-upward-lsystem_trace
LIBSYSTEM_DARWIN_LDFLAGS = -all_load -nostdlib -L/usr/lib/system -umbrella System $(LIBCOMPILER_RT_LDFLAGS) $(LIBDYLD_LDFLAGS) $(LIBSYSCALL_LDFLAGS) $(LIBM_LDFLAGS) $(LIBMALLOC_LDFLAGS) $(LIBPLATFORM_LDFLAGS) $(LIBPTHREAD_LDFLAGS) $(LIBPLATFORM_LDFLAGS) $(LIBC_LDFLAGS) $(LIBDISPATCH_LDFLAGS) $(LIBXPC_LDFLAGS)