📄 stdlib.h
字号:
extern void srand(unsigned int /*seed*/);
/*
* uses its argument as a seed for a new sequence of pseudo-random numbers
* to be returned by subsequent calls to rand. If srand is then called with
* the same seed value, the sequence of pseudo-random numbers is repeated.
* If rand is called before any calls to srand have been made, the same
* sequence is generated as when srand is first called with a seed value
* of 1.
*/
extern void *calloc(size_t /*nmemb*/, size_t /*size*/);
/*
* allocates space for an array of nmemb objects, each of whose size is
* 'size'. The space is initialised to all bits zero.
* Returns: either a null pointer or a pointer to the allocated space.
*/
extern void free(void * /*ptr*/);
/*
* causes the space pointed to by ptr to be deallocated (i.e., made
* available for further allocation). If ptr is a null pointer, no action
* occurs. Otherwise, if ptr does not match a pointer earlier returned by
* calloc, malloc or realloc or if the space has been deallocated by a call
* to free or realloc, the behaviour is undefined.
*/
extern void *malloc(size_t /*size*/);
/*
* allocates space for an object whose size is specified by 'size' and whose
* value is indeterminate.
* Returns: either a null pointer or a pointer to the allocated space.
*/
extern void *realloc(void * /*ptr*/, size_t /*size*/);
/*
* changes the size of the object pointed to by ptr to the size specified by
* size. The contents of the object shall be unchanged up to the lesser of
* the new and old sizes. If the new size is larger, the value of the newly
* allocated portion of the object is indeterminate. If ptr is a null
* pointer, the realloc function behaves like a call to malloc for the
* specified size. Otherwise, if ptr does not match a pointer earlier
* returned by calloc, malloc or realloc, or if the space has been
* deallocated by a call to free or realloc, the behaviour is undefined.
* If the space cannot be allocated, the object pointed to by ptr is
* unchanged. If size is zero and ptr is not a null pointer, the object it
* points to is freed.
* Returns: either a null pointer or a pointer to the possibly moved
* allocated space.
*/
typedef int (*__heapprt)(void *, char const *, ...);
extern void __heapstats(int (* /*dprint*/)(void * /*param*/,
char const * /*format*/, ...),
void * /*param*/);
/*
* reports current heap statistics (eg. number of free blocks in
* the free-list). Output is as implementation-defined free-form
* text, provided via the dprint function. `param' gives an
* extra data word to pass to dprint. You can call
* __heapstats(fprintf,stdout) by casting fprintf to the above
* function type; the typedef `__heapprt' is provided for this
* purpose.
*
* `dprint' will not be called while the heap is being examined,
* so it can allocate memory itself without trouble.
*/
extern int __heapvalid(int (* /*dprint*/)(void * /*param*/,
char const * /*format*/, ...),
void * /*param*/, int /*verbose*/);
/*
* performs a consistency check on the heap. Errors are reported
* through dprint, like __heapstats. If `verbose' is nonzero,
* full diagnostic information on the heap state is printed out.
*
* This routine probably won't work if the heap isn't a
* contiguous chunk (for example, if __user_heap_extend has been
* overridden).
*
* `dprint' may be called while the heap is being examined or
* even in an invalid state, so it must perform no memory
* allocation. In particular, if `dprint' calls (or is) a stdio
* function, the stream it outputs to must already have either
* been written to or been setvbuf'ed, or else the system will
* allocate buffer space for it on the first call to dprint.
*/
extern void abort(void);
/*
* causes abnormal program termination to occur, unless the signal SIGABRT
* is being caught and the signal handler does not return. Whether open
* output streams are flushed or open streams are closed or temporary
* files removed is implementation-defined.
* An implementation-defined form of the status 'unsuccessful termination'
* is returned to the host environment by means of a call to
* raise(SIGABRT).
*/
extern int atexit(void (* /*func*/)(void));
/*
* registers the function pointed to by func, to be called without its
* arguments at normal program termination. It is possible to register at
* least 32 functions.
* Returns: zero if the registration succeeds, nonzero if it fails.
*/
extern void exit(int /*status*/);
/*
* causes normal program termination to occur. If more than one call to the
* exit function is executed by a program, the behaviour is undefined.
* First, all functions registered by the atexit function are called, in the
* reverse order of their registration.
* Next, all open output streams are flushed, all open streams are closed,
* and all files created by the tmpfile function are removed.
* Finally, control is returned to the host environment. If the value of
* status is zero or EXIT_SUCCESS, an implementation-defined form of the
* status 'successful termination' is returned. If the value of status is
* EXIT_FAILURE, an implementation-defined form of the status
* 'unsuccessful termination' is returned. Otherwise the status returned
* is implementation-defined.
*/
extern char *getenv(const char * /*name*/);
/*
* searches the environment list, provided by the host environment, for a
* string that matches the string pointed to by name. The set of environment
* names and the method for altering the environment list are
* implementation-defined.
* Returns: a pointer to a string associated with the matched list member.
* The array pointed to shall not be modified by the program, but
* may be overwritten by a subsequent call to the getenv function.
* If the specified name cannot be found, a null pointer is
* returned.
*/
extern int system(const char * /*string*/);
/*
* passes the string pointed to by string to the host environment to be
* executed by a command processor in an implementation-defined manner.
* A null pointer may be used for string, to inquire whether a command
* processor exists.
*
* Returns: If the argument is a null pointer, the system function returns
* non-zero only if a command processor is available. If the
* argument is not a null pointer, the system function returns an
* implementation-defined value.
*/
extern void *bsearch(const void * /*key*/, const void * /*base*/,
size_t /*nmemb*/, size_t /*size*/,
int (* /*compar*/)(const void *, const void *));
/*
* searches an array of nmemb objects, the initial member of which is
* pointed to by base, for a member that matches the object pointed to by
* key. The size of each member of the array is specified by size.
* The contents of the array shall be in ascending sorted order according to
* a comparison function pointed to by compar, which is called with two
* arguments that point to the key object and to an array member, in that
* order. The function shall return an integer less than, equal to, or
* greater than zero if the key object is considered, respectively, to be
* less than, to match, or to be greater than the array member.
* Returns: a pointer to a matching member of the array, or a null pointer
* if no match is found. If two members compare as equal, which
* member is matched is unspecified.
*/
extern void qsort(void * /*base*/, size_t /*nmemb*/, size_t /*size*/,
int (* /*compar*/)(const void *, const void *));
/*
* sorts an array of nmemb objects, the initial member of which is pointed
* to by base. The size of each object is specified by size.
* The contents of the array shall be in ascending order according to a
* comparison function pointed to by compar, which is called with two
* arguments that point to the objects being compared. The function shall
* return an integer less than, equal to, or greater than zero if the first
* argument is considered to be respectively less than, equal to, or greater
* than the second. If two members compare as equal, their order in the
* sorted array is unspecified.
*/
extern int abs(int /*j*/);
/*
* computes the absolute value of an integer j. If the result cannot be
* represented, the behaviour is undefined.
* Returns: the absolute value.
*/
extern div_t div(int /*numer*/, int /*denom*/);
/*
* computes the quotient and remainder of the division of the numerator
* numer by the denominator denom. If the division is inexact, the resulting
* quotient is the integer of lesser magnitude that is the nearest to the
* algebraic quotient. If the result cannot be represented, the behaviour is
* undefined; otherwise, quot * denom + rem shall equal numer.
* Returns: a structure of type div_t, comprising both the quotient and the
* remainder. the structure shall contain the following members,
* in either order.
* int quot; int rem;
*/
extern long int labs(long int /*j*/);
/*
* computes the absolute value of an long integer j. If the result cannot be
* represented, the behaviour is undefined.
* Returns: the absolute value.
*/
#ifdef __cplusplus
extern "C++" inline long abs(long int x) { return labs(x); }
#endif
extern ldiv_t ldiv(long int /*numer*/, long int /*denom*/);
/*
* computes the quotient and remainder of the division of the numerator
* numer by the denominator denom. If the division is inexact, the sign of
* the resulting quotient is that of the algebraic quotient, and the
* magnitude of the resulting quotient is the largest integer less than the
* magnitude of the algebraic quotient. If the result cannot be represented,
* the behaviour is undefined; otherwise, quot * denom + rem shall equal
* numer.
* Returns: a structure of type ldiv_t, comprising both the quotient and the
* remainder. the structure shall contain the following members,
* in either order.
* long int quot; long int rem;
*/
#ifdef __cplusplus
extern "C++" inline ldiv_t div(long int __numer, long int __denom) {
return ldiv(__numer, __denom);
}
#endif
#ifndef __STRICT_ANSI__
extern long long llabs(long long /*j*/);
/*
* computes the absolute value of a long long integer j. If the
* result cannot be represented, the behaviour is undefined.
* Returns: the absolute value.
*/
#ifdef __cplusplus
extern "C++" inline long long abs(long long x) { return llabs(x); }
#endif
extern lldiv_t lldiv(long long /*numer*/, long long /*denom*/);
/*
* computes the quotient and remainder of the division of the numerator
* numer by the denominator denom. If the division is inexact, the sign of
* the resulting quotient is that of the algebraic quotient, and the
* magnitude of the resulting quotient is the largest integer less than the
* magnitude of the algebraic quotient. If the result cannot be represented,
* the behaviour is undefined; otherwise, quot * denom + rem shall equal
* numer.
* Returns: a structure of type lldiv_t, comprising both the quotient and the
* remainder. the structure shall contain the following members,
* in either order.
* long long quot; long long rem;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -