Loading...
include/stdlib.h Libc-391 Libc-594.9.4
--- Libc/Libc-391/include/stdlib.h
+++ Libc/Libc-594.9.4/include/stdlib.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2005 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000, 2002 - 2008 Apple Inc. All rights reserved.
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
@@ -58,13 +58,14 @@
 #ifndef _STDLIB_H_
 #define _STDLIB_H_
 
-#include <sys/cdefs.h>
+#include <Availability.h>
+
 #include <_types.h>
 #if !defined(_ANSI_SOURCE)
 #include <sys/wait.h>
-#if !defined(_POSIX_C_SOURCE)
+#if (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE))
 #include <alloca.h>
-#endif /* !_POSIX_C_SOURCE */
+#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */
 #endif /* !_ANSI_SOURCE */
 
 #ifndef	_SIZE_T
@@ -74,7 +75,7 @@
 typedef	__darwin_size_t		size_t;
 #endif
 
-#if !defined(_ANSI_SOURCE) && !defined(_POSIX_C_SOURCE)
+#if !defined(_ANSI_SOURCE) && (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE))
 #ifndef _CT_RUNE_T
 #define _CT_RUNE_T
 typedef	__darwin_ct_rune_t	ct_rune_t;
@@ -84,7 +85,7 @@
 #define _RUNE_T
 typedef __darwin_rune_t   	rune_t;
 #endif
-#endif
+#endif	/* !_ANSI_SOURCE && (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */
 
 #ifndef	__cplusplus
 #ifndef	_WCHAR_T
@@ -135,13 +136,21 @@
 #endif /* _USE_EXTENDED_LOCALES_ */
 #endif /* MB_CUR_MAX */
 
-#if !defined(_ANSI_SOURCE) && !defined(_POSIX_C_SOURCE) \
+#if !defined(_ANSI_SOURCE) && (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)) \
     && defined(_USE_EXTENDED_LOCALES_) && !defined(MB_CUR_MAX_L)
 #define	MB_CUR_MAX_L(x)	(___mb_cur_max_l(x))
 #endif
+//Begin-Libc
+/* f must be a literal string */
+#define LIBC_ABORT(f,...)	abort_report_np("%s:%s:%u: " f, __FILE__, __func__, __LINE__, ## __VA_ARGS__)
+//End-Libc
 
 __BEGIN_DECLS
 void	 abort(void) __dead2;
+//Begin-Libc
+__private_extern__
+void	 abort_report_np(const char *, ...) __dead2 __printflike(1, 2);
+//End-Libc
 int	 abs(int) __pure2;
 int	 atexit(void (*)(void));
 double	 atof(const char *);
@@ -169,13 +178,14 @@
 int	 mblen(const char *, size_t);
 size_t	 mbstowcs(wchar_t * __restrict , const char * __restrict, size_t);
 int	 mbtowc(wchar_t * __restrict, const char * __restrict, size_t);
+int 	 posix_memalign(void **, size_t, size_t);
 void	 qsort(void *, size_t, size_t,
 	    int (*)(const void *, const void *));
 int	 rand(void);
 void	*realloc(void *, size_t);
 void	 srand(unsigned);
-double	 strtod(const char *, char **);
-float	 strtof(const char *, char **);
+double	 strtod(const char *, char **) __DARWIN_ALIAS(strtod);
+float	 strtof(const char *, char **) __DARWIN_ALIAS(strtof);
 long	 strtol(const char *, char **, int);
 long double
 	 strtold(const char *, char **) __DARWIN_LDBL_COMPAT(strtold);
@@ -189,7 +199,15 @@
 unsigned long long
 	 strtoull(const char *, char **, int);
 #endif /* !__DARWIN_NO_LONG_LONG */
-int	 system(const char *);
+//Begin-Libc
+#ifndef LIBC_ALIAS_SYSTEM
+//End-Libc
+int	 system(const char *) __DARWIN_ALIAS_C(system);
+//Begin-Libc
+#else /* LIBC_ALIAS_SYSTEM */
+int	 system(const char *) LIBC_ALIAS_C(system);
+#endif /* !LIBC_ALIAS_SYSTEM */
+//End-Libc
 size_t	 wcstombs(char * __restrict, const wchar_t * __restrict, size_t);
 int	 wctomb(char *, wchar_t);
 
@@ -218,14 +236,59 @@
 long	 nrand48(unsigned short[3]);
 int	 posix_openpt(int);
 char	*ptsname(int);
+//Begin-Libc
+#ifndef LIBC_ALIAS_PUTENV
+//End-Libc
 int	 putenv(char *) __DARWIN_ALIAS(putenv);
+//Begin-Libc
+#else /* LIBC_ALIAS_PUTENV */
+int	 putenv(char *) LIBC_ALIAS(putenv);
+#endif /* !LIBC_ALIAS_PUTENV */
+//End-Libc
 long	 random(void);
-char	*realpath(const char *, char *resolved_path);
+int	 rand_r(unsigned *);
+//Begin-Libc
+#ifdef __LIBC__
+#ifndef LIBC_ALIAS_REALPATH
+char	*realpath(const char * __restrict, char * __restrict) __DARWIN_EXTSN(realpath);
+#else /* LIBC_ALIAS_REALPATH */
+#ifdef VARIANT_DARWINEXTSN
+char	*realpath(const char * __restrict, char * __restrict) LIBC_EXTSN(realpath);
+#else /* !VARIANT_DARWINEXTSN */
+char	*realpath(const char * __restrict, char * __restrict) LIBC_ALIAS(realpath);
+#endif /* VARIANT_DARWINEXTSN */
+#endif /* !LIBC_ALIAS_REALPATH */
+#else /* !__LIBC__ */
+//End-Libc
+#if (__DARWIN_UNIX03 && !defined(_POSIX_C_SOURCE)) || defined(_DARWIN_C_SOURCE) || defined(_DARWIN_BETTER_REALPATH)
+char	*realpath(const char * __restrict, char * __restrict) __DARWIN_EXTSN(realpath);
+#else /* (!__DARWIN_UNIX03 || _POSIX_C_SOURCE) && !_DARWIN_C_SOURCE && !_DARWIN_BETTER_REALPATH */
+char	*realpath(const char * __restrict, char * __restrict) __DARWIN_ALIAS(realpath);
+#endif /* (__DARWIN_UNIX03 && _POSIX_C_SOURCE) || _DARWIN_C_SOURCE || _DARWIN_BETTER_REALPATH */
+//Begin-Libc
+#endif /* __LIBC__ */
+//End-Libc
 unsigned short
 	*seed48(unsigned short[3]);
+//Begin-Libc
+#ifndef LIBC_ALIAS_SETENV
+//End-Libc
 int	 setenv(const char *, const char *, int) __DARWIN_ALIAS(setenv);
+//Begin-Libc
+#else /* LIBC_ALIAS_SETENV */
+int	 setenv(const char *, const char *, int) LIBC_ALIAS(setenv);
+#endif /* !LIBC_ALIAS_SETENV */
+//End-Libc
 #if __DARWIN_UNIX03
+//Begin-Libc
+#ifndef LIBC_ALIAS_SETKEY
+//End-Libc
 void	 setkey(const char *) __DARWIN_ALIAS(setkey);
+//Begin-Libc
+#else /* LIBC_ALIAS_SETKEY */
+void	 setkey(const char *) LIBC_ALIAS(setkey);
+#endif /* !LIBC_ALIAS_SETKEY */
+//End-Libc
 #else /* !__DARWIN_UNIX03 */
 int	 setkey(const char *);
 #endif /* __DARWIN_UNIX03 */
@@ -238,13 +301,21 @@
 #endif /* __DARWIN_UNIX03 */
 int	 unlockpt(int);
 #if __DARWIN_UNIX03
+//Begin-Libc
+#ifndef LIBC_ALIAS_UNSETENV
+//End-Libc
 int	 unsetenv(const char *) __DARWIN_ALIAS(unsetenv);
+//Begin-Libc
+#else /* LIBC_ALIAS_UNSETENV */
+int	 unsetenv(const char *) LIBC_ALIAS(unsetenv);
+#endif /* !LIBC_ALIAS_UNSETENV */
+//End-Libc
 #else /* !__DARWIN_UNIX03 */
 void	 unsetenv(const char *);
 #endif /* __DARWIN_UNIX03 */
-#endif
-
-#if !defined(_ANSI_SOURCE) && !defined(_POSIX_C_SOURCE)
+#endif	/* !_ANSI_SOURCE */
+
+#if !defined(_ANSI_SOURCE) && (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE))
 #include <machine/types.h>
 
 #ifndef _DEV_T
@@ -261,6 +332,11 @@
 	 arc4random(void);
 void	 arc4random_addrandom(unsigned char *dat, int datlen);
 void	 arc4random_stir(void);
+#ifdef __BLOCKS__
+int	 atexit_b(void (^)(void));
+void	*bsearch_b(const void *, const void *, size_t,
+	    size_t, int (^)(const void *, const void *));
+#endif /* __BLOCKS__ */
 
 	 /* getcap(3) functions */
 char	*cgetcap(char *, const char *, int);
@@ -274,7 +350,7 @@
 int	 cgetstr(char *, const char *, char **);
 int	 cgetustr(char *, const char *, char **);
 
-int	 daemon(int, int);
+int	 daemon(int, int) __DARWIN_1050(daemon) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0,__MAC_10_5,__IPHONE_2_0,__IPHONE_2_0);
 char	*devname(dev_t, mode_t);
 char	*devname_r(dev_t, mode_t, char *buf, int len);
 char	*getbsize(int *, long *);
@@ -284,8 +360,28 @@
 
 int	 heapsort(void *, size_t, size_t,
 	    int (*)(const void *, const void *));
+#ifdef __BLOCKS__
+int	 heapsort_b(void *, size_t, size_t,
+	    int (^)(const void *, const void *));
+#endif /* __BLOCKS__ */
 int	 mergesort(void *, size_t, size_t,
 	    int (*)(const void *, const void *));
+#ifdef __BLOCKS__
+int	 mergesort_b(void *, size_t, size_t,
+	    int (^)(const void *, const void *));
+#endif /* __BLOCKS__ */
+void	 psort(void *, size_t, size_t,
+	    int (*)(const void *, const void *));
+#ifdef __BLOCKS__
+void	 psort_b(void *, size_t, size_t,
+	    int (^)(const void *, const void *));
+#endif /* __BLOCKS__ */
+void	 psort_r(void *, size_t, size_t, void *,
+	    int (*)(void *, const void *, const void *));
+#ifdef __BLOCKS__
+void	 qsort_b(void *, size_t, size_t,
+	    int (^)(const void *, const void *));
+#endif /* __BLOCKS__ */
 void	 qsort_r(void *, size_t, size_t, void *,
 	    int (*)(void *, const void *, const void *));
 int	 radixsort(const unsigned char **, int, const unsigned char *,
@@ -295,7 +391,6 @@
 	    unsigned);
 void	 sranddev(void);
 void	 srandomdev(void);
-int	 rand_r(unsigned *);
 void	*reallocf(void *, size_t);
 #if !__DARWIN_NO_LONG_LONG
 long long
@@ -305,6 +400,11 @@
 #endif /* !__DARWIN_NO_LONG_LONG */
 extern char *suboptarg;		/* getsubopt(3) external variable */
 void	*valloc(size_t);
+#endif	/* !_ANSI_SOURCE && !_POSIX_SOURCE */
+
+/* Poison the following routines if -fshort-wchar is set */
+#if !defined(__cplusplus) && defined(__WCHAR_MAX__) && __WCHAR_MAX__ <= 0xffffU
+#pragma GCC poison mbstowcs mbtowc wcstombs wctomb
 #endif
 __END_DECLS