X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=includes%2Fstdlib.h;h=b94ceafeeeea2fca5a61fe6fde5b11b12f4c2b69;hb=e921387af8d68b18babcd7e098b97479965b7663;hp=9ed464efb237c06d073b88320a34976800c72eab;hpb=e1c526e9bad3f6e69391e94059096145390508d3;p=pdclib diff --git a/includes/stdlib.h b/includes/stdlib.h index 9ed464e..b94ceaf 100644 --- a/includes/stdlib.h +++ b/includes/stdlib.h @@ -1,4 +1,4 @@ -/* 7.20 General utilities +/* General utilities This file is part of the Public Domain C Library (PDCLib). Permission is granted to use, modify, and / or redistribute at will. @@ -7,7 +7,10 @@ #ifndef _PDCLIB_STDLIB_H #define _PDCLIB_STDLIB_H _PDCLIB_STDLIB_H #include <_PDCLIB_int.h> -_PDCLIB_BEGIN_EXTERN_C + +#ifdef __cplusplus +extern "C" { +#endif #ifndef _PDCLIB_SIZE_T_DEFINED #define _PDCLIB_SIZE_T_DEFINED _PDCLIB_SIZE_T_DEFINED @@ -92,19 +95,26 @@ void srand( unsigned int seed ) _PDCLIB_nothrow; /* Memory management functions */ -/* Allocate a chunk of heap memory of given size. If request could not be +/* Allocate a chunk of memory of given size. If request could not be satisfied, return NULL. Otherwise, return a pointer to the allocated memory. Memory contents are undefined. */ void * malloc( size_t size ) _PDCLIB_nothrow; -/* Allocate a chunk of heap memory that is large enough to hold nmemb elements - of the given size, and zero-initialize that memory. If request could not be +/* Allocate a chunk of memory that is large enough to hold nmemb elements of + the given size, and zero-initialize that memory. If request could not be satisfied, return NULL. Otherwise, return a pointer to the allocated memory. */ void * calloc( size_t nmemb, size_t size ) _PDCLIB_nothrow; +/* Allocate a chunk of memory of given size, with specified alignment (which + must be a power of two; if it is not, the next greater power of two is + used). If request could not be satisfied, return NULL. Otherwise, return + a pointer to the allocated memory. +*/ +void * aligned_alloc( size_t alignment, size_t size ) _PDCLIB_nothrow; + /* De-allocate a chunk of heap memory previously allocated using malloc(), calloc(), or realloc(), and pointed to by ptr. If ptr does not match a pointer previously returned by the mentioned allocation functions, or @@ -148,7 +158,7 @@ _PDCLIB_noreturn void abort( void ) _PDCLIB_nothrow; reverse order of registration (last-in, first-out). Returns zero if registration is successfull, nonzero if it failed. */ -int atexit( void (*func)( void ) ) _PDCLIB_nothrow; +int atexit( void (*func)( void ) ) _PDCLIB_nothrow; /* Normal process termination. Functions registered by atexit() (see above) are called, streams flushed, files closed and temporary files removed before the @@ -248,5 +258,8 @@ size_t mbstowcs( wchar_t * _PDCLIB_restrict pwcs, const char * _PDCLIB_restrict size_t wcstombs( char * _PDCLIB_restrict s, const wchar_t * _PDCLIB_restrict pwcs, size_t n ); */ -_PDCLIB_END_EXTERN_C +#ifdef __cplusplus +} +#endif + #endif