📄 stdlib.h
字号:
/* Copyright (C) 1991-1999, 2000, 2001 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *//* * ISO C99 Standard: 7.20 General utilities <stdlib.h> */#ifndef _STDLIB_H#include <features.h>/* Get size_t, wchar_t and NULL from <stddef.h>. */#define __need_size_t#ifndef __need_malloc_and_calloc# define __need_wchar_t# define __need_NULL#endif#include <stddef.h>__BEGIN_DECLS#ifndef __need_malloc_and_calloc#define _STDLIB_H 1#if defined __USE_XOPEN && !defined _SYS_WAIT_H/* XPG requires a few symbols from <sys/wait.h> being defined. */# include <bits/waitflags.h># include <bits/waitstatus.h># ifdef __USE_BSD/* Lots of hair to allow traditional BSD use of `union wait' as well as POSIX.1 use of `int' for the status word. */# if defined __GNUC__ && !defined __cplusplus# define __WAIT_INT(status) \ (__extension__ ({ union { __typeof(status) __in; int __i; } __u; \ __u.__in = (status); __u.__i; }))# else# define __WAIT_INT(status) (*(int *) &(status))# endif/* This is the type of the argument to `wait'. The funky union causes redeclarations with ether `int *' or `union wait *' to be allowed without complaint. __WAIT_STATUS_DEFN is the type used in the actual function definitions. */# if !defined __GNUC__ || __GNUC__ < 2 || defined __cplusplus# define __WAIT_STATUS void *# define __WAIT_STATUS_DEFN void *# else/* This works in GCC 2.6.1 and later. */typedef union { union wait *__uptr; int *__iptr; } __WAIT_STATUS __attribute__ ((__transparent_union__));# define __WAIT_STATUS_DEFN int *# endif# else /* Don't use BSD. */# define __WAIT_INT(status) (status)# define __WAIT_STATUS int *# define __WAIT_STATUS_DEFN int *# endif /* Use BSD. *//* Define the macros <sys/wait.h> also would define this way. */# define WEXITSTATUS(status) __WEXITSTATUS(__WAIT_INT(status))# define WTERMSIG(status) __WTERMSIG(__WAIT_INT(status))# define WSTOPSIG(status) __WSTOPSIG(__WAIT_INT(status))# define WIFEXITED(status) __WIFEXITED(__WAIT_INT(status))# define WIFSIGNALED(status) __WIFSIGNALED(__WAIT_INT(status))# define WIFSTOPPED(status) __WIFSTOPPED(__WAIT_INT(status))#endif /* X/Open and <sys/wait.h> not included. *//* Returned by `div'. */typedef struct { int quot; /* Quotient. */ int rem; /* Remainder. */ } div_t;/* Returned by `ldiv'. */#ifndef __ldiv_t_definedtypedef struct { long int quot; /* Quotient. */ long int rem; /* Remainder. */ } ldiv_t;# define __ldiv_t_defined 1#endif#if defined __USE_ISOC99 && !defined __lldiv_t_defined/* Returned by `lldiv'. */__extension__ typedef struct { long long int quot; /* Quotient. */ long long int rem; /* Remainder. */ } lldiv_t;# define __lldiv_t_defined 1#endif/* The largest number rand will return (same as INT_MAX). */#define RAND_MAX 2147483647/* We define these the same for all machines. Changes from this to the outside world should be done in `_exit'. */#define EXIT_FAILURE 1 /* Failing exit status. */#define EXIT_SUCCESS 0 /* Successful exit status. *//* Maximum length of a multibyte character in the current locale. */#define MB_CUR_MAX (__ctype_get_mb_cur_max ())extern size_t __ctype_get_mb_cur_max (void) __THROW;/* Convert a string to a floating-point number. */extern double atof (__const char *__nptr) __THROW __attribute_pure__;/* Convert a string to an integer. */extern int atoi (__const char *__nptr) __THROW __attribute_pure__;/* Convert a string to a long integer. */extern long int atol (__const char *__nptr) __THROW __attribute_pure__;#if defined __USE_ISOC99 || (defined __GLIBC_HAVE_LONG_LONG && defined __USE_MISC)/* Convert a string to a long long integer. */__extension__ extern long long int atoll (__const char *__nptr) __THROW __attribute_pure__;#endif/* Convert a string to a floating-point number. */extern double strtod (__const char *__restrict __nptr, char **__restrict __endptr) __THROW;#ifdef __USE_ISOC99/* Likewise for `float' and `long double' sizes of floating-point numbers. */extern float strtof (__const char *__restrict __nptr, char **__restrict __endptr) __THROW;extern long double strtold (__const char *__restrict __nptr, char **__restrict __endptr) __THROW;#endif/* Convert a string to a long integer. */extern long int strtol (__const char *__restrict __nptr, char **__restrict __endptr, int __base) __THROW;/* Convert a string to an unsigned long integer. */extern unsigned long int strtoul (__const char *__restrict __nptr, char **__restrict __endptr, int __base) __THROW;#if defined __GLIBC_HAVE_LONG_LONG && defined __USE_BSD/* Convert a string to a quadword integer. */__extension__extern long long int strtoq (__const char *__restrict __nptr, char **__restrict __endptr, int __base) __THROW;/* Convert a string to an unsigned quadword integer. */__extension__extern unsigned long long int strtouq (__const char *__restrict __nptr, char **__restrict __endptr, int __base) __THROW;#endif /* GCC and use BSD. */#if defined __USE_ISOC99 || (defined __GLIBC_HAVE_LONG_LONG && defined __USE_MISC)/* These functions will part of the standard C library in ISO C99. *//* Convert a string to a quadword integer. */__extension__extern long long int strtoll (__const char *__restrict __nptr, char **__restrict __endptr, int __base) __THROW;/* Convert a string to an unsigned quadword integer. */__extension__extern unsigned long long int strtoull (__const char *__restrict __nptr, char **__restrict __endptr, int __base) __THROW;#endif /* ISO C99 or GCC and use MISC. */#ifdef __USE_GNU/* The concept of one static locale per category is not very well thought out. Many applications will need to process its data using information from several different locales. Another application is the implementation of the internationalization handling in the upcoming ISO C++ standard library. To support this another set of the functions using locale data exist which have an additional argument. Attention: all these functions are *not* standardized in any form. This is a proof-of-concept implementation. *//* Structure for reentrant locale using functions. This is an (almost) opaque type for the user level programs. */# include <xlocale.h>/* Special versions of the functions above which take the locale to use as an additional parameter. */extern long int __strtol_l (__const char *__restrict __nptr, char **__restrict __endptr, int __base, __locale_t __loc) __THROW;extern unsigned long int __strtoul_l (__const char *__restrict __nptr, char **__restrict __endptr, int __base, __locale_t __loc) __THROW;__extension__extern long long int __strtoll_l (__const char *__restrict __nptr, char **__restrict __endptr, int __base, __locale_t __loc) __THROW;__extension__extern unsigned long long int __strtoull_l (__const char *__restrict __nptr, char **__restrict __endptr, int __base, __locale_t __loc) __THROW;extern double __strtod_l (__const char *__restrict __nptr, char **__restrict __endptr, __locale_t __loc) __THROW;extern float __strtof_l (__const char *__restrict __nptr, char **__restrict __endptr, __locale_t __loc) __THROW;extern long double __strtold_l (__const char *__restrict __nptr, char **__restrict __endptr, __locale_t __loc) __THROW;#endif /* GNU *//* The internal entry points for `strtoX' take an extra flag argument saying whether or not to parse locale-dependent number grouping. */extern double __strtod_internal (__const char *__restrict __nptr, char **__restrict __endptr, int __group) __THROW;extern float __strtof_internal (__const char *__restrict __nptr, char **__restrict __endptr, int __group) __THROW;extern long double __strtold_internal (__const char *__restrict __nptr, char **__restrict __endptr, int __group) __THROW;#ifndef __strtol_internal_definedextern long int __strtol_internal (__const char *__restrict __nptr, char **__restrict __endptr, int __base, int __group) __THROW;# define __strtol_internal_defined 1#endif#ifndef __strtoul_internal_definedextern unsigned long int __strtoul_internal (__const char *__restrict __nptr, char **__restrict __endptr, int __base, int __group) __THROW;# define __strtoul_internal_defined 1#endif#if defined __GNUC__ || defined __USE_ISOC99# ifndef __strtoll_internal_defined__extension__extern long long int __strtoll_internal (__const char *__restrict __nptr, char **__restrict __endptr, int __base, int __group) __THROW;# define __strtoll_internal_defined 1# endif# ifndef __strtoull_internal_defined__extension__extern unsigned long long int __strtoull_internal (__const char * __restrict __nptr, char **__restrict __endptr, int __base, int __group) __THROW;# define __strtoull_internal_defined 1# endif#endif /* GCC */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -