diff --git a/build.sh b/build.sh index 6fbfb14..aa147bf 100755 --- a/build.sh +++ b/build.sh @@ -184,17 +184,14 @@ fi pushd $SDK_DIR/MacOSX$SDK_VERSION.sdk &>/dev/null set +e -if [ $PLATFORM == "FreeBSD" ] || [ $PLATFORM == "OpenBSD" ]; then - files=$(echo $SDK_DIR/MacOSX$SDK_VERSION.sdk/System/Library/Frameworks/Kernel.framework/Versions/A/Headers/std*.h) - for file in $files; do - rm -f usr/include/$(basename $file) +files=$(echo $BASE_DIR/oclang/quirks/*.h) +for file in $files; do + filename=$(basename $file) + if [ ! -f "usr/include/$filename" ]; then + rm -f usr/include/$filename # Broken symlink cp $file usr/include - done - cp -f $BASE_DIR/oclang/quirks/tgmath.h usr/include -fi -if [ ! -f "usr/include/float.h" ]; then - cp -f $BASE_DIR/oclang/quirks/float.h usr/include -fi + fi +done set -e popd &>/dev/null diff --git a/oclang/quirks/LICENSE b/oclang/quirks/LICENSE new file mode 100644 index 0000000..cd52ac7 --- /dev/null +++ b/oclang/quirks/LICENSE @@ -0,0 +1,26 @@ +stddef.h and stdint.h were taken from https://opensource.apple.com/tarballs/Libc/ + +APSL applies + +/* + * Copyright (c) 1999 Apple Computer, 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@ + */ diff --git a/oclang/quirks/stddef.h b/oclang/quirks/stddef.h new file mode 100644 index 0000000..6832cf7 --- /dev/null +++ b/oclang/quirks/stddef.h @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2000-2013 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@ + */ +/* $OpenBSD: stddef.h,v 1.2 1997/09/21 10:45:52 niklas Exp $ */ +/* $NetBSD: stddef.h,v 1.4 1994/10/26 00:56:26 cgd Exp $ */ + +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. 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. + * + * @(#)stddef.h 5.5 (Berkeley) 4/3/91 + */ + +#ifndef __STDDEF_H__ +#define __STDDEF_H__ + +#include <_types.h> + +#include +#include +#include +#include + +#if defined(__STDC_WANT_LIB_EXT1__) && __STDC_WANT_LIB_EXT1__ >= 1 +#include +#endif /* __STDC_WANT_LIB_EXT1__ >= 1 */ + +/* DO NOT REMOVE THIS COMMENT: fixincludes needs to see: + * _GCC_SIZE_T */ +#include + +#include + +#if !defined(_ANSI_SOURCE) && (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)) +#include +#endif /* !_ANSI_SOURCE && (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ + +#if (defined (__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) \ + || (defined(__cplusplus) && __cplusplus >= 201103L) +typedef long double max_align_t; +#endif + +#endif /* __STDDEF_H__ */ diff --git a/oclang/quirks/stdint.h b/oclang/quirks/stdint.h new file mode 100644 index 0000000..f4bb4cd --- /dev/null +++ b/oclang/quirks/stdint.h @@ -0,0 +1,205 @@ +/* + * Copyright (c) 2000-2010 Apple Inc. + * All rights reserved. + */ + +#ifndef _STDINT_H_ +#define _STDINT_H_ + +#if __LP64__ +#define __WORDSIZE 64 +#else +#define __WORDSIZE 32 +#endif + +/* from ISO/IEC 988:1999 spec */ + +/* 7.18.1.1 Exact-width integer types */ +#include +#include +#include +#include + +#include <_types/_uint8_t.h> +#include <_types/_uint16_t.h> +#include <_types/_uint32_t.h> +#include <_types/_uint64_t.h> + +/* 7.18.1.2 Minimum-width integer types */ +typedef int8_t int_least8_t; +typedef int16_t int_least16_t; +typedef int32_t int_least32_t; +typedef int64_t int_least64_t; +typedef uint8_t uint_least8_t; +typedef uint16_t uint_least16_t; +typedef uint32_t uint_least32_t; +typedef uint64_t uint_least64_t; + + +/* 7.18.1.3 Fastest-width integer types */ +typedef int8_t int_fast8_t; +typedef int16_t int_fast16_t; +typedef int32_t int_fast32_t; +typedef int64_t int_fast64_t; +typedef uint8_t uint_fast8_t; +typedef uint16_t uint_fast16_t; +typedef uint32_t uint_fast32_t; +typedef uint64_t uint_fast64_t; + + +/* 7.18.1.4 Integer types capable of holding object pointers */ + +#include +#include +#include + + +/* 7.18.1.5 Greatest-width integer types */ +#include <_types/_intmax_t.h> +#include <_types/_uintmax_t.h> + +/* 7.18.4 Macros for integer constants */ +#define INT8_C(v) (v) +#define INT16_C(v) (v) +#define INT32_C(v) (v) +#define INT64_C(v) (v ## LL) + +#define UINT8_C(v) (v) +#define UINT16_C(v) (v) +#define UINT32_C(v) (v ## U) +#define UINT64_C(v) (v ## ULL) + +#ifdef __LP64__ +#define INTMAX_C(v) (v ## L) +#define UINTMAX_C(v) (v ## UL) +#else +#define INTMAX_C(v) (v ## LL) +#define UINTMAX_C(v) (v ## ULL) +#endif + +/* 7.18.2 Limits of specified-width integer types: + * These #defines specify the minimum and maximum limits + * of each of the types declared above. + * + * They must have "the same type as would an expression that is an + * object of the corresponding type converted according to the integer + * promotion". + */ + + +/* 7.18.2.1 Limits of exact-width integer types */ +#define INT8_MAX 127 +#define INT16_MAX 32767 +#define INT32_MAX 2147483647 +#define INT64_MAX 9223372036854775807LL + +#define INT8_MIN -128 +#define INT16_MIN -32768 + /* + Note: the literal "most negative int" cannot be written in C -- + the rules in the standard (section 6.4.4.1 in C99) will give it + an unsigned type, so INT32_MIN (and the most negative member of + any larger signed type) must be written via a constant expression. + */ +#define INT32_MIN (-INT32_MAX-1) +#define INT64_MIN (-INT64_MAX-1) + +#define UINT8_MAX 255 +#define UINT16_MAX 65535 +#define UINT32_MAX 4294967295U +#define UINT64_MAX 18446744073709551615ULL + +/* 7.18.2.2 Limits of minimum-width integer types */ +#define INT_LEAST8_MIN INT8_MIN +#define INT_LEAST16_MIN INT16_MIN +#define INT_LEAST32_MIN INT32_MIN +#define INT_LEAST64_MIN INT64_MIN + +#define INT_LEAST8_MAX INT8_MAX +#define INT_LEAST16_MAX INT16_MAX +#define INT_LEAST32_MAX INT32_MAX +#define INT_LEAST64_MAX INT64_MAX + +#define UINT_LEAST8_MAX UINT8_MAX +#define UINT_LEAST16_MAX UINT16_MAX +#define UINT_LEAST32_MAX UINT32_MAX +#define UINT_LEAST64_MAX UINT64_MAX + +/* 7.18.2.3 Limits of fastest minimum-width integer types */ +#define INT_FAST8_MIN INT8_MIN +#define INT_FAST16_MIN INT16_MIN +#define INT_FAST32_MIN INT32_MIN +#define INT_FAST64_MIN INT64_MIN + +#define INT_FAST8_MAX INT8_MAX +#define INT_FAST16_MAX INT16_MAX +#define INT_FAST32_MAX INT32_MAX +#define INT_FAST64_MAX INT64_MAX + +#define UINT_FAST8_MAX UINT8_MAX +#define UINT_FAST16_MAX UINT16_MAX +#define UINT_FAST32_MAX UINT32_MAX +#define UINT_FAST64_MAX UINT64_MAX + +/* 7.18.2.4 Limits of integer types capable of holding object pointers */ + +#if __WORDSIZE == 64 +#define INTPTR_MAX 9223372036854775807L +#else +#define INTPTR_MAX 2147483647L +#endif +#define INTPTR_MIN (-INTPTR_MAX-1) + +#if __WORDSIZE == 64 +#define UINTPTR_MAX 18446744073709551615UL +#else +#define UINTPTR_MAX 4294967295UL +#endif + +/* 7.18.2.5 Limits of greatest-width integer types */ +#define INTMAX_MAX INTMAX_C(9223372036854775807) +#define UINTMAX_MAX UINTMAX_C(18446744073709551615) +#define INTMAX_MIN (-INTMAX_MAX-1) + +/* 7.18.3 "Other" */ +#if __WORDSIZE == 64 +#define PTRDIFF_MIN INTMAX_MIN +#define PTRDIFF_MAX INTMAX_MAX +#else +#define PTRDIFF_MIN INT32_MIN +#define PTRDIFF_MAX INT32_MAX +#endif + +#define SIZE_MAX UINTPTR_MAX + +#if defined(__STDC_WANT_LIB_EXT1__) && __STDC_WANT_LIB_EXT1__ >= 1 +#define RSIZE_MAX (SIZE_MAX >> 1) +#endif + +#ifndef WCHAR_MAX +# ifdef __WCHAR_MAX__ +# define WCHAR_MAX __WCHAR_MAX__ +# else +# define WCHAR_MAX 0x7fffffff +# endif +#endif + +/* WCHAR_MIN should be 0 if wchar_t is an unsigned type and + (-WCHAR_MAX-1) if wchar_t is a signed type. Unfortunately, + it turns out that -fshort-wchar changes the signedness of + the type. */ +#ifndef WCHAR_MIN +# if WCHAR_MAX == 0xffff +# define WCHAR_MIN 0 +# else +# define WCHAR_MIN (-WCHAR_MAX-1) +# endif +#endif + +#define WINT_MIN INT32_MIN +#define WINT_MAX INT32_MAX + +#define SIG_ATOMIC_MIN INT32_MIN +#define SIG_ATOMIC_MAX INT32_MAX + +#endif /* _STDINT_H_ */