Unverified Commit 6d4f6aea authored by Dimitris Papastamos's avatar Dimitris Papastamos Committed by GitHub
Browse files

Merge pull request #1528 from antonio-nino-diaz-arm/an/libc

libc: Cleanup library
parents 11dfe0b4 8422a840
/*
* Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef SIZET_
typedef unsigned int size_t;
#define SIZET_
#endif
#ifndef _PTRDIFF_T
typedef long ptrdiff_t;
#define _PTRDIFF_T
#endif
/*
* Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#define INT8_MAX 0x7F
#define INT8_MIN (-INT8_MAX - 1)
#define UINT8_MAX 0xFFU
#define INT16_MAX 0x7FFF
#define INT16_MIN (-INT16_MAX - 1)
#define UINT16_MAX 0xFFFFU
#define INT32_MAX 0x7FFFFFFF
#define INT32_MIN (-INT32_MAX - 1)
#define UINT32_MAX 0xFFFFFFFFU
#define INT64_MAX 0x7FFFFFFFFFFFFFFFLL
#define INT64_MIN (-INT64_MAX - 1LL)
#define UINT64_MAX 0xFFFFFFFFFFFFFFFFULL
#define INT_LEAST8_MIN INT8_MIN
#define INT_LEAST8_MAX INT8_MAX
#define UINT_LEAST8_MAX UINT8_MAX
#define INT_LEAST16_MIN INT16_MIN
#define INT_LEAST16_MAX INT16_MAX
#define UINT_LEAST16_MAX UINT16_MAX
#define INT_LEAST32_MIN INT32_MIN
#define INT_LEAST32_MAX INT32_MAX
#define UINT_LEAST32_MAX UINT32_MAX
#define INT_LEAST64_MIN INT64_MIN
#define INT_LEAST64_MAX INT64_MAX
#define UINT_LEAST64_MAX UINT64_MAX
#define INT_FAST8_MIN INT32_MIN
#define INT_FAST8_MAX INT32_MAX
#define UINT_FAST8_MAX UINT32_MAX
#define INT_FAST16_MIN INT32_MIN
#define INT_FAST16_MAX INT32_MAX
#define UINT_FAST16_MAX UINT32_MAX
#define INT_FAST32_MIN INT32_MIN
#define INT_FAST32_MAX INT32_MAX
#define UINT_FAST32_MAX UINT32_MAX
#define INT_FAST64_MIN INT64_MIN
#define INT_FAST64_MAX INT64_MAX
#define UINT_FAST64_MAX UINT64_MAX
#define INTPTR_MIN INT32_MIN
#define INTPTR_MAX INT32_MAX
#define UINTPTR_MAX UINT32_MAX
#define INTMAX_MIN INT64_MIN
#define INTMAX_MAX INT64_MAX
#define UINTMAX_MAX UINT64_MAX
#define PTRDIFF_MIN INT32_MIN
#define PTRDIFF_MAX INT32_MAX
#define SIZE_MAX UINT32_MAX
#define INT8_C(x) x
#define INT16_C(x) x
#define INT32_C(x) x
#define INT64_C(x) x ## LL
#define UINT8_C(x) x
#define UINT16_C(x) x
#define UINT32_C(x) x ## U
#define UINT64_C(x) x ## ULL
#define INTMAX_C(x) x ## LL
#define UINTMAX_C(x) x ## ULL
typedef signed char int8_t;
typedef short int16_t;
typedef int int32_t;
typedef long long int64_t;
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
typedef unsigned int uint32_t;
typedef unsigned long long uint64_t;
typedef signed char int8_least_t;
typedef short int16_least_t;
typedef int int32_least_t;
typedef long long int64_least_t;
typedef unsigned char uint8_least_t;
typedef unsigned short uint16_least_t;
typedef unsigned int uint32_least_t;
typedef unsigned long long uint64_least_t;
typedef int int8_fast_t;
typedef int int16_fast_t;
typedef int int32_fast_t;
typedef long long int64_fast_t;
typedef unsigned int uint8_fast_t;
typedef unsigned int uint16_fast_t;
typedef unsigned int uint32_fast_t;
typedef unsigned long long uint64_fast_t;
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long long intmax_t;
typedef unsigned long long uintmax_t;
typedef long register_t;
typedef unsigned long u_register_t;
/*
* Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef SIZET_
typedef unsigned int size_t;
#define SIZET_
#endif
#ifndef SSIZET_
typedef int ssize_t;
#define SSIZET_
#endif
/*
* Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef SIZET_
typedef unsigned int size_t;
#define SIZET_
#endif
#define EXIT_FAILURE 1
#define EXIT_SUCCESS 0
/*
* Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef SIZET_
typedef unsigned int size_t;
#define SIZET_
#endif
/*
* Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef SIZET_
typedef unsigned int size_t;
#define SIZET_
#endif
typedef long int time_t;
/*- /*-
* SPDX-License-Identifier: BSD-3-Clause
*
* Copyright (c) 2001 David E. O'Brien * Copyright (c) 2001 David E. O'Brien
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
...@@ -30,14 +32,14 @@ ...@@ -30,14 +32,14 @@
* $FreeBSD$ * $FreeBSD$
*/ */
/* /*
* Portions copyright (c) 2017, ARM Limited and Contributors. * Portions copyright (c) 2018, ARM Limited and Contributors.
* All rights reserved. * All rights reserved.
*/ */
#ifndef _MACHINE_ENDIAN_H_ #ifndef AARCH64_ENDIAN_H
#define _MACHINE_ENDIAN_H_ #define AARCH64_ENDIAN_H
#include <sys/_types.h> #include <stdint.h>
/* /*
* Definitions for byte order, according to byte significance from low * Definitions for byte order, according to byte significance from low
...@@ -63,80 +65,38 @@ ...@@ -63,80 +65,38 @@
#define __htonl(x) (__bswap32(x)) #define __htonl(x) (__bswap32(x))
#define __htons(x) (__bswap16(x)) #define __htons(x) (__bswap16(x))
#ifdef AARCH32 static __inline uint64_t
static __inline __uint64_t __bswap64(uint64_t x)
__bswap64(__uint64_t _x)
{
return ((_x >> 56) | ((_x >> 40) & 0xff00) | ((_x >> 24) & 0xff0000) |
((_x >> 8) & 0xff000000) | ((_x << 8) & ((__uint64_t)0xff << 32)) |
((_x << 24) & ((__uint64_t)0xff << 40)) |
((_x << 40) & ((__uint64_t)0xff << 48)) | ((_x << 56)));
}
static __inline __uint32_t
__bswap32_var(__uint32_t v)
{
__uint32_t t1;
__asm __volatile("eor %1, %0, %0, ror #16\n"
"bic %1, %1, #0x00ff0000\n"
"mov %0, %0, ror #8\n"
"eor %0, %0, %1, lsr #8\n"
: "+r" (v), "=r" (t1));
return (v);
}
static __inline __uint16_t
__bswap16_var(__uint16_t v)
{
__uint32_t ret = v & 0xffff;
__asm __volatile(
"mov %0, %0, ror #8\n"
"orr %0, %0, %0, lsr #16\n"
"bic %0, %0, %0, lsl #16"
: "+r" (ret));
return ((__uint16_t)ret);
}
#elif defined AARCH64
static __inline __uint64_t
__bswap64(__uint64_t x)
{ {
__uint64_t ret; uint64_t ret;
__asm __volatile("rev %0, %1\n" __asm __volatile("rev %0, %1\n"
: "=&r" (ret), "+r" (x)); : "=&r" (ret), "+r" (x));
return (ret); return (ret);
} }
static __inline __uint32_t static __inline uint32_t
__bswap32_var(__uint32_t v) __bswap32_var(uint32_t v)
{ {
__uint32_t ret; uint32_t ret;
__asm __volatile("rev32 %x0, %x1\n" __asm __volatile("rev32 %x0, %x1\n"
: "=&r" (ret), "+r" (v)); : "=&r" (ret), "+r" (v));
return (ret); return (ret);
} }
static __inline __uint16_t static __inline uint16_t
__bswap16_var(__uint16_t v) __bswap16_var(uint16_t v)
{ {
__uint32_t ret; uint32_t ret;
__asm __volatile("rev16 %w0, %w1\n" __asm __volatile("rev16 %w0, %w1\n"
: "=&r" (ret), "+r" (v)); : "=&r" (ret), "+r" (v));
return ((__uint16_t)ret); return ((uint16_t)ret);
} }
#else
#error "Only AArch32 or AArch64 supported"
#endif /* AARCH32 */
#ifdef __OPTIMIZE__ #ifdef __OPTIMIZE__
...@@ -151,13 +111,13 @@ __bswap16_var(__uint16_t v) ...@@ -151,13 +111,13 @@ __bswap16_var(__uint16_t v)
(((x) & 0x00ff) << 8)) (((x) & 0x00ff) << 8))
#define __bswap16(x) \ #define __bswap16(x) \
((__uint16_t)(__builtin_constant_p(x) ? \ ((uint16_t)(__builtin_constant_p(x) ? \
__bswap16_constant(x) : \ __bswap16_constant((uint16_t)(x)) : \
__bswap16_var(x))) __bswap16_var(x)))
#define __bswap32(x) \ #define __bswap32(x) \
((__uint32_t)(__builtin_constant_p(x) ? \ ((uint32_t)(__builtin_constant_p(x) ? \
__bswap32_constant(x) : \ __bswap32_constant((uint32_t)(x)) : \
__bswap32_var(x))) __bswap32_var(x)))
#else #else
...@@ -165,4 +125,4 @@ __bswap16_var(__uint16_t v) ...@@ -165,4 +125,4 @@ __bswap16_var(__uint16_t v)
#define __bswap32(x) __bswap32_var(x) #define __bswap32(x) __bswap32_var(x)
#endif /* __OPTIMIZE__ */ #endif /* __OPTIMIZE__ */
#endif /* !_MACHINE_ENDIAN_H_ */ #endif /* AARCH64_ENDIAN_H */
/*
* Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#define SCHAR_MAX 0x7F
#define SCHAR_MIN (-SCHAR_MIN - 1)
#define CHAR_MAX 0x7F
#define CHAR_MIN (-CHAR_MAX - 1)
#define UCHAR_MAX 0xFFU
#define SHRT_MAX 0x7FFF
#define SHRT_MIN (-SHRT_MAX - 1)
#define USHRT_MAX 0xFFFFU
#define INT_MAX 0x7FFFFFFF
#define INT_MIN (-INT_MAX - 1)
#define UINT_MAX 0xFFFFFFFFU
#define LONG_MAX 0x7FFFFFFFFFFFFFFFL
#define LONG_MIN (-LONG_MAX - 1L)
#define ULONG_MAX 0xFFFFFFFFFFFFFFFFUL
#define LLONG_MAX 0x7FFFFFFFFFFFFFFFLL
#define LLONG_MIN (-LLONG_MAX - 1LL)
#define ULLONG_MAX 0xFFFFFFFFFFFFFFFFULL
#define __LONG_BIT 64
#define __WORD_BIT 32
/*
* Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef SIZET_
typedef unsigned long size_t;
#define SIZET_
#endif
#ifndef _PTRDIFF_T
typedef long ptrdiff_t;
#define _PTRDIFF_T
#endif
/*
* Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#define INT8_MAX 0x7F
#define INT8_MIN (-INT8_MAX - 1)
#define UINT8_MAX 0xFFU
#define INT16_MAX 0x7FFF
#define INT16_MIN (-INT16_MAX - 1)
#define UINT16_MAX 0xFFFFU
#define INT32_MAX 0x7FFFFFFF
#define INT32_MIN (-INT32_MAX - 1)
#define UINT32_MAX 0xFFFFFFFFU
#define INT64_MAX 0x7FFFFFFFFFFFFFFFLL
#define INT64_MIN (-INT64_MAX - 1LL)
#define UINT64_MAX 0xFFFFFFFFFFFFFFFFULL
#define INT_LEAST8_MIN INT8_MIN
#define INT_LEAST8_MAX INT8_MAX
#define UINT_LEAST8_MAX UINT8_MAX
#define INT_LEAST16_MIN INT16_MIN
#define INT_LEAST16_MAX INT16_MAX
#define UINT_LEAST16_MAX UINT16_MAX
#define INT_LEAST32_MIN INT32_MIN
#define INT_LEAST32_MAX INT32_MAX
#define UINT_LEAST32_MAX UINT32_MAX
#define INT_LEAST64_MIN INT64_MIN
#define INT_LEAST64_MAX INT64_MAX
#define UINT_LEAST64_MAX UINT64_MAX
#define INT_FAST8_MIN INT32_MIN
#define INT_FAST8_MAX INT32_MAX
#define UINT_FAST8_MAX UINT32_MAX
#define INT_FAST16_MIN INT32_MIN
#define INT_FAST16_MAX INT32_MAX
#define UINT_FAST16_MAX UINT32_MAX
#define INT_FAST32_MIN INT32_MIN
#define INT_FAST32_MAX INT32_MAX
#define UINT_FAST32_MAX UINT32_MAX
#define INT_FAST64_MIN INT64_MIN
#define INT_FAST64_MAX INT64_MAX
#define UINT_FAST64_MAX UINT64_MAX
#define INTPTR_MIN INT64_MIN
#define INTPTR_MAX INT64_MAX
#define UINTPTR_MAX UINT64_MAX
#define INTMAX_MIN INT64_MIN
#define INTMAX_MAX INT64_MAX
#define UINTMAX_MAX UINT64_MAX
#define PTRDIFF_MIN INT64_MIN
#define PTRDIFF_MAX INT64_MAX
#define SIZE_MAX UINT64_MAX
#define INT8_C(x) x
#define INT16_C(x) x
#define INT32_C(x) x
#define INT64_C(x) x ## LL
#define UINT8_C(x) x
#define UINT16_C(x) x
#define UINT32_C(x) x ## U
#define UINT64_C(x) x ## ULL
#define INTMAX_C(x) x ## L
#define UINTMAX_C(x) x ## ULL
typedef signed char int8_t;
typedef short int16_t;
typedef int int32_t;
typedef long long int64_t;
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
typedef unsigned int uint32_t;
typedef unsigned long long uint64_t;
typedef signed char int8_least_t;
typedef short int16_least_t;
typedef int int32_least_t;
typedef long long int64_least_t;
typedef unsigned char uint8_least_t;
typedef unsigned short uint16_least_t;
typedef unsigned int uint32_least_t;
typedef unsigned long long uint64_least_t;
typedef int int8_fast_t;
typedef int int16_fast_t;
typedef int int32_fast_t;
typedef long long int64_fast_t;
typedef unsigned int uint8_fast_t;
typedef unsigned int uint16_fast_t;
typedef unsigned int uint32_fast_t;
typedef unsigned long long uint64_fast_t;
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long intmax_t;
typedef unsigned long uintmax_t;
typedef long register_t;
typedef unsigned long u_register_t;
/*
* Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef SIZET_
typedef unsigned long size_t;
#define SIZET_
#endif
#ifndef SSIZET_
typedef long ssize_t;
#define SSIZET_
#endif
/*
* Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef SIZET_
typedef unsigned long size_t;
#define SIZET_
#endif
#define EXIT_FAILURE 1
#define EXIT_SUCCESS 0
/*
* Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef SIZET_
typedef unsigned long size_t;
#define SIZET_
#endif
/*
* Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef SIZET_
typedef unsigned long size_t;
#define SIZET_
#endif
typedef long int time_t;
/*-
* Copyright (c) 1992, 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.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)assert.h 8.2 (Berkeley) 1/21/94
* $FreeBSD$
*/
/* /*
* Portions copyright (c) 2017, ARM Limited and Contributors. * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
* All rights reserved. *
* SPDX-License-Identifier: BSD-3-Clause
*/ */
#ifndef _ASSERT_H_ #ifndef ASSERT_H
#define _ASSERT_H_ #define ASSERT_H
#include <cdefs.h>
#include <debug.h> #include <debug.h>
#include <platform_def.h> #include <platform_def.h>
#include <sys/cdefs.h>
#ifndef PLAT_LOG_LEVEL_ASSERT #ifndef PLAT_LOG_LEVEL_ASSERT
#define PLAT_LOG_LEVEL_ASSERT LOG_LEVEL #define PLAT_LOG_LEVEL_ASSERT LOG_LEVEL
#endif #endif
#if ENABLE_ASSERTIONS #if ENABLE_ASSERTIONS
#define _assert(e) assert(e)
# if PLAT_LOG_LEVEL_ASSERT >= LOG_LEVEL_VERBOSE # if PLAT_LOG_LEVEL_ASSERT >= LOG_LEVEL_VERBOSE
# define assert(e) ((e) ? (void)0 : __assert(__FILE__, __LINE__, #e)) # define assert(e) ((e) ? (void)0 : __assert(__FILE__, __LINE__, #e))
# elif PLAT_LOG_LEVEL_ASSERT >= LOG_LEVEL_INFO # elif PLAT_LOG_LEVEL_ASSERT >= LOG_LEVEL_INFO
# define assert(e) ((e) ? (void)0 : __assert(__FILE__, __LINE__)) # define assert(e) ((e) ? (void)0 : __assert(__FILE__, __LINE__))
# else # else
# define assert(e) ((e) ? (void)0 : __assert()) # define assert(e) ((e) ? (void)0 : __assert())
# endif # endif
#else #else
#define assert(e) ((void)0) #define assert(e) ((void)0)
#define _assert(e) ((void)0)
#endif /* ENABLE_ASSERTIONS */ #endif /* ENABLE_ASSERTIONS */
__BEGIN_DECLS
#if PLAT_LOG_LEVEL_ASSERT >= LOG_LEVEL_VERBOSE #if PLAT_LOG_LEVEL_ASSERT >= LOG_LEVEL_VERBOSE
void __assert(const char *, unsigned int, const char *) __dead2; __dead2 void __assert(const char *file, unsigned int line,
const char *assertion);
#elif PLAT_LOG_LEVEL_ASSERT >= LOG_LEVEL_INFO #elif PLAT_LOG_LEVEL_ASSERT >= LOG_LEVEL_INFO
void __assert(const char *, unsigned int) __dead2; __dead2 void __assert(const char *file, unsigned int line);
#else #else
void __assert(void) __dead2; __dead2 void __assert(void);
#endif #endif
__END_DECLS
#endif /* !_ASSERT_H_ */ #endif /* ASSERT_H */
/*
* Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef CDEFS_H
#define CDEFS_H
#define __dead2 __attribute__((__noreturn__))
#define __deprecated __attribute__((__deprecated__))
#define __packed __attribute__((__packed__))
#define __used __attribute__((__used__))
#define __unused __attribute__((__unused__))
#define __aligned(x) __attribute__((__aligned__(x)))
#define __section(x) __attribute__((__section__(x)))
#define __printflike(fmtarg, firstvararg) \
__attribute__((__format__ (__printf__, fmtarg, firstvararg)))
#define __weak_reference(sym, alias) \
__asm__(".weak alias"); \
__asm__(".equ alias, sym")
#define __STRING(x) #x
#define __XSTRING(x) __STRING(x)
#endif /* CDEFS_H */
/*- /*-
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
*
* Copyright (c) 2002 Thomas Moestl <tmm@FreeBSD.org> * Copyright (c) 2002 Thomas Moestl <tmm@FreeBSD.org>
* All rights reserved. * All rights reserved.
* *
...@@ -25,34 +27,18 @@ ...@@ -25,34 +27,18 @@
* *
* $FreeBSD$ * $FreeBSD$
*/ */
/*
* Portions copyright (c) 2018, ARM Limited and Contributors.
* All rights reserved.
*/
#ifndef ENDIAN_H
#define ENDIAN_H
#include <cdefs.h>
#include <stdint.h>
#include <endian_.h>
#ifndef _SYS_ENDIAN_H_
#define _SYS_ENDIAN_H_
#include <sys/cdefs.h>
#include <sys/_types.h>
#include <machine/endian.h>
#ifndef _UINT8_T_DECLARED
typedef __uint8_t uint8_t;
#define _UINT8_T_DECLARED
#endif
#ifndef _UINT16_T_DECLARED
typedef __uint16_t uint16_t;
#define _UINT16_T_DECLARED
#endif
#ifndef _UINT32_T_DECLARED
typedef __uint32_t uint32_t;
#define _UINT32_T_DECLARED
#endif
#ifndef _UINT64_T_DECLARED
typedef __uint64_t uint64_t;
#define _UINT64_T_DECLARED
#endif
/* /*
* General byte order swapping functions. * General byte order swapping functions.
*/ */
...@@ -202,4 +188,4 @@ le64enc(void *pp, uint64_t u) ...@@ -202,4 +188,4 @@ le64enc(void *pp, uint64_t u)
le32enc(p + 4, (uint32_t)(u >> 32)); le32enc(p + 4, (uint32_t)(u >> 32));
} }
#endif /* _SYS_ENDIAN_H_ */ #endif /* SYS_ENDIAN_H */
/*- /*-
* SPDX-License-Identifier: BSD-3-Clause
*
* Copyright (c) 1982, 1986, 1989, 1993 * Copyright (c) 1982, 1986, 1989, 1993
* The Regents of the University of California. All rights reserved. * The Regents of the University of California. All rights reserved.
* (c) UNIX System Laboratories, Inc. * (c) UNIX System Laboratories, Inc.
...@@ -15,7 +17,7 @@ ...@@ -15,7 +17,7 @@
* 2. Redistributions in binary form must reproduce the above copyright * 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution. * 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 * may be used to endorse or promote products derived from this software
* without specific prior written permission. * without specific prior written permission.
* *
...@@ -34,17 +36,13 @@ ...@@ -34,17 +36,13 @@
* @(#)errno.h 8.5 (Berkeley) 1/21/94 * @(#)errno.h 8.5 (Berkeley) 1/21/94
* $FreeBSD$ * $FreeBSD$
*/ */
/*
* Portions copyright (c) 2018, ARM Limited and Contributors.
* All rights reserved.
*/
#ifndef _SYS_ERRNO_H_ #ifndef ERRNO_H
#define _SYS_ERRNO_H_ #define ERRNO_H
#ifndef _KERNEL
#include <sys/cdefs.h>
__BEGIN_DECLS
int * __error(void);
__END_DECLS
#define errno (* __error())
#endif
#define EPERM 1 /* Operation not permitted */ #define EPERM 1 /* Operation not permitted */
#define ENOENT 2 /* No such file or directory */ #define ENOENT 2 /* No such file or directory */
...@@ -61,9 +59,7 @@ __END_DECLS ...@@ -61,9 +59,7 @@ __END_DECLS
#define ENOMEM 12 /* Cannot allocate memory */ #define ENOMEM 12 /* Cannot allocate memory */
#define EACCES 13 /* Permission denied */ #define EACCES 13 /* Permission denied */
#define EFAULT 14 /* Bad address */ #define EFAULT 14 /* Bad address */
#ifndef _POSIX_SOURCE
#define ENOTBLK 15 /* Block device required */ #define ENOTBLK 15 /* Block device required */
#endif
#define EBUSY 16 /* Device busy */ #define EBUSY 16 /* Device busy */
#define EEXIST 17 /* File exists */ #define EEXIST 17 /* File exists */
#define EXDEV 18 /* Cross-device link */ #define EXDEV 18 /* Cross-device link */
...@@ -74,9 +70,7 @@ __END_DECLS ...@@ -74,9 +70,7 @@ __END_DECLS
#define ENFILE 23 /* Too many open files in system */ #define ENFILE 23 /* Too many open files in system */
#define EMFILE 24 /* Too many open files */ #define EMFILE 24 /* Too many open files */
#define ENOTTY 25 /* Inappropriate ioctl for device */ #define ENOTTY 25 /* Inappropriate ioctl for device */
#ifndef _POSIX_SOURCE
#define ETXTBSY 26 /* Text file busy */ #define ETXTBSY 26 /* Text file busy */
#endif
#define EFBIG 27 /* File too large */ #define EFBIG 27 /* File too large */
#define ENOSPC 28 /* No space left on device */ #define ENOSPC 28 /* No space left on device */
#define ESPIPE 29 /* Illegal seek */ #define ESPIPE 29 /* Illegal seek */
...@@ -90,7 +84,6 @@ __END_DECLS ...@@ -90,7 +84,6 @@ __END_DECLS
/* non-blocking and interrupt i/o */ /* non-blocking and interrupt i/o */
#define EAGAIN 35 /* Resource temporarily unavailable */ #define EAGAIN 35 /* Resource temporarily unavailable */
#ifndef _POSIX_SOURCE
#define EWOULDBLOCK EAGAIN /* Operation would block */ #define EWOULDBLOCK EAGAIN /* Operation would block */
#define EINPROGRESS 36 /* Operation now in progress */ #define EINPROGRESS 36 /* Operation now in progress */
#define EALREADY 37 /* Operation already in progress */ #define EALREADY 37 /* Operation already in progress */
...@@ -125,18 +118,14 @@ __END_DECLS ...@@ -125,18 +118,14 @@ __END_DECLS
#define ECONNREFUSED 61 /* Connection refused */ #define ECONNREFUSED 61 /* Connection refused */
#define ELOOP 62 /* Too many levels of symbolic links */ #define ELOOP 62 /* Too many levels of symbolic links */
#endif /* _POSIX_SOURCE */
#define ENAMETOOLONG 63 /* File name too long */ #define ENAMETOOLONG 63 /* File name too long */
/* should be rearranged */ /* should be rearranged */
#ifndef _POSIX_SOURCE
#define EHOSTDOWN 64 /* Host is down */ #define EHOSTDOWN 64 /* Host is down */
#define EHOSTUNREACH 65 /* No route to host */ #define EHOSTUNREACH 65 /* No route to host */
#endif /* _POSIX_SOURCE */
#define ENOTEMPTY 66 /* Directory not empty */ #define ENOTEMPTY 66 /* Directory not empty */
/* quotas & mush */ /* quotas & mush */
#ifndef _POSIX_SOURCE
#define EPROCLIM 67 /* Too many processes */ #define EPROCLIM 67 /* Too many processes */
#define EUSERS 68 /* Too many users */ #define EUSERS 68 /* Too many users */
#define EDQUOT 69 /* Disc quota exceeded */ #define EDQUOT 69 /* Disc quota exceeded */
...@@ -149,12 +138,10 @@ __END_DECLS ...@@ -149,12 +138,10 @@ __END_DECLS
#define EPROGUNAVAIL 74 /* RPC prog. not avail */ #define EPROGUNAVAIL 74 /* RPC prog. not avail */
#define EPROGMISMATCH 75 /* Program version wrong */ #define EPROGMISMATCH 75 /* Program version wrong */
#define EPROCUNAVAIL 76 /* Bad procedure for program */ #define EPROCUNAVAIL 76 /* Bad procedure for program */
#endif /* _POSIX_SOURCE */
#define ENOLCK 77 /* No locks available */ #define ENOLCK 77 /* No locks available */
#define ENOSYS 78 /* Function not implemented */ #define ENOSYS 78 /* Function not implemented */
#ifndef _POSIX_SOURCE
#define EFTYPE 79 /* Inappropriate file type or format */ #define EFTYPE 79 /* Inappropriate file type or format */
#define EAUTH 80 /* Authentication error */ #define EAUTH 80 /* Authentication error */
#define ENEEDAUTH 81 /* Need authenticator */ #define ENEEDAUTH 81 /* Need authenticator */
...@@ -166,28 +153,17 @@ __END_DECLS ...@@ -166,28 +153,17 @@ __END_DECLS
#define ENOATTR 87 /* Attribute not found */ #define ENOATTR 87 /* Attribute not found */
#define EDOOFUS 88 /* Programming error */ #define EDOOFUS 88 /* Programming error */
#endif /* _POSIX_SOURCE */
#define EBADMSG 89 /* Bad message */ #define EBADMSG 89 /* Bad message */
#define EMULTIHOP 90 /* Multihop attempted */ #define EMULTIHOP 90 /* Multihop attempted */
#define ENOLINK 91 /* Link has been severed */ #define ENOLINK 91 /* Link has been severed */
#define EPROTO 92 /* Protocol error */ #define EPROTO 92 /* Protocol error */
#ifndef _POSIX_SOURCE
#define ENOTCAPABLE 93 /* Capabilities insufficient */ #define ENOTCAPABLE 93 /* Capabilities insufficient */
#define ECAPMODE 94 /* Not permitted in capability mode */ #define ECAPMODE 94 /* Not permitted in capability mode */
#endif /* _POSIX_SOURCE */ #define ENOTRECOVERABLE 95 /* State not recoverable */
#define EOWNERDEAD 96 /* Previous owner died */
#ifndef _POSIX_SOURCE
#define ELAST 94 /* Must be equal largest errno */
#endif /* _POSIX_SOURCE */
#ifdef _KERNEL #define ELAST 96 /* Must be equal largest errno */
/* pseudo-errors returned inside kernel to modify return to process */
#define ERESTART (-1) /* restart syscall */
#define EJUSTRETURN (-2) /* don't modify regs, just return */
#define ENOIOCTL (-3) /* ioctl not handled by this layer */
#define EDIRIOCTL (-4) /* do direct ioctl in GEOM */
#endif
#endif #endif /* ERRNO_H */
/*-
* Copyright (c) 2001 Mike Barcroft <mike@FreeBSD.org>
* 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.
*
* $FreeBSD$
*/
#ifndef _INTTYPES_H_
#define _INTTYPES_H_
#include <machine/_inttypes.h>
#include <sys/stdint.h>
typedef struct {
intmax_t quot; /* Quotient. */
intmax_t rem; /* Remainder. */
} imaxdiv_t;
__BEGIN_DECLS
#ifdef _XLOCALE_H_
#include <xlocale/_inttypes.h>
#endif
intmax_t imaxabs(intmax_t) __pure2;
imaxdiv_t imaxdiv(intmax_t, intmax_t) __pure2;
intmax_t strtoimax(const char *__restrict, char **__restrict, int);
uintmax_t strtoumax(const char *__restrict, char **__restrict, int);
__END_DECLS
#endif /* !_INTTYPES_H_ */
/*
* Copyright (c) 2012-2017 Roberto E. Vargas Caballero
*
* SPDX-License-Identifier: BSD-3-Clause
*/
/*
* Portions copyright (c) 2018, ARM Limited and Contributors.
* All rights reserved.
*/
#ifndef LIMITS_H
#define LIMITS_H
#include <limits_.h>
#define CHAR_BIT 8
#define MB_LEN_MAX 1
#endif /* LIMITS_H */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment