forked from nuttx/nuttx-update
Can't use formal parameter name 'template' in stdlib.h. Causes C++ compilation errors. Noted by Lorenz Meier
This commit is contained in:
parent
f54667a7e9
commit
ee22104762
4 changed files with 48 additions and 18 deletions
|
@ -49,10 +49,15 @@
|
||||||
|
|
||||||
namespace std
|
namespace std
|
||||||
{
|
{
|
||||||
|
// Random number generation
|
||||||
|
|
||||||
using ::srand;
|
using ::srand;
|
||||||
using ::rand;
|
using ::rand;
|
||||||
|
|
||||||
|
// Environment variable support
|
||||||
|
|
||||||
#ifndef CONFIG_DISABLE_ENIVRON
|
#ifndef CONFIG_DISABLE_ENIVRON
|
||||||
|
using ::get_environ_ptr;
|
||||||
using ::getenv;
|
using ::getenv;
|
||||||
using ::putenv;
|
using ::putenv;
|
||||||
using ::clearenv;
|
using ::clearenv;
|
||||||
|
@ -60,6 +65,8 @@ namespace std
|
||||||
using ::unsetenv;
|
using ::unsetenv;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Process exit functions
|
||||||
|
|
||||||
using ::exit;
|
using ::exit;
|
||||||
using ::abort;
|
using ::abort;
|
||||||
#ifdef CONFIG_SCHED_ATEXIT
|
#ifdef CONFIG_SCHED_ATEXIT
|
||||||
|
@ -69,10 +76,22 @@ namespace std
|
||||||
using ::on_exit;
|
using ::on_exit;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// String to binary conversions
|
||||||
|
|
||||||
using ::strtol;
|
using ::strtol;
|
||||||
using ::strtoul;
|
using ::strtoul;
|
||||||
|
#ifdef CONFIG_HAVE_LONG_LONG
|
||||||
|
using ::strtoll;
|
||||||
|
using ::strtoull;
|
||||||
|
#endif
|
||||||
using ::strtod;
|
using ::strtod;
|
||||||
|
|
||||||
|
// Binary to string conversions
|
||||||
|
|
||||||
|
using ::itoa;
|
||||||
|
|
||||||
|
// Memory Management
|
||||||
|
|
||||||
using ::malloc;
|
using ::malloc;
|
||||||
using ::free;
|
using ::free;
|
||||||
using ::realloc;
|
using ::realloc;
|
||||||
|
@ -80,6 +99,17 @@ namespace std
|
||||||
using ::zalloc;
|
using ::zalloc;
|
||||||
using ::calloc;
|
using ::calloc;
|
||||||
using ::mallinfo;
|
using ::mallinfo;
|
||||||
|
|
||||||
|
// Misc.
|
||||||
|
|
||||||
|
using ::abs;
|
||||||
|
using ::labs;
|
||||||
|
#ifdef CONFIG_HAVE_LONG_LONG
|
||||||
|
using ::llabs;
|
||||||
|
#endif
|
||||||
|
using ::mktemp;
|
||||||
|
using ::mkstemp;
|
||||||
|
using ::qsort;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // __INCLUDE_CXX_CSTDLIB
|
#endif // __INCLUDE_CXX_CSTDLIB
|
||||||
|
|
|
@ -182,8 +182,8 @@ long int labs(long int j);
|
||||||
#ifdef CONFIG_HAVE_LONG_LONG
|
#ifdef CONFIG_HAVE_LONG_LONG
|
||||||
long long int llabs(long long int j);
|
long long int llabs(long long int j);
|
||||||
#endif
|
#endif
|
||||||
int mktemp(FAR char *template);
|
int mktemp(FAR char *path_template);
|
||||||
int mkstemp(FAR char *template);
|
int mkstemp(FAR char *path_template);
|
||||||
|
|
||||||
/* Sorting */
|
/* Sorting */
|
||||||
|
|
||||||
|
|
|
@ -195,18 +195,18 @@ static void copy_base62(FAR char *dest, int len)
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* The mkstemp() function replaces the contents of the string pointed to
|
* The mkstemp() function replaces the contents of the string pointed to
|
||||||
* by template by a unique filename, and returns a file descriptor for the
|
* by path_template by a unique filename, and returns a file descriptor
|
||||||
* file open for reading and writing. The function thus prevents any
|
* for the file open for reading and writing. The function thus prevents
|
||||||
* possible race condition between testing whether the file exists and
|
* any possible race condition between testing whether the file exists and
|
||||||
* opening it for use. The string in template should look like a filename
|
* opening it for use. The string in path_template should look like a
|
||||||
* with six trailing 'X' s; mkstemp() replaces each 'X' with a character
|
* filename with six trailing 'X' s; mkstemp() replaces each 'X' with a
|
||||||
* from the portable filename character set. The characters are chosen
|
* character from the portable filename character set. The characters are
|
||||||
* such that the resulting name does not duplicate the name of an existing
|
* chosen such that the resulting name does not duplicate the name of an
|
||||||
* file at the time of a call to mkstemp().
|
* existing file at the time of a call to mkstemp().
|
||||||
*
|
*
|
||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
* template - The base file name that will be modified to produce the
|
* path_template - The base file name that will be modified to produce
|
||||||
* unique file name. This must be a full path beginning with /tmp.
|
* the unique file name. This must be a full path beginning with /tmp.
|
||||||
* This function will modify only the first XXXXXX characters within
|
* This function will modify only the first XXXXXX characters within
|
||||||
* that full path.
|
* that full path.
|
||||||
*
|
*
|
||||||
|
@ -217,7 +217,7 @@ static void copy_base62(FAR char *dest, int len)
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
int mkstemp(FAR char *template)
|
int mkstemp(FAR char *path_template)
|
||||||
{
|
{
|
||||||
uint8_t base62[MAX_XS];
|
uint8_t base62[MAX_XS];
|
||||||
uint32_t retries;
|
uint32_t retries;
|
||||||
|
@ -229,12 +229,12 @@ int mkstemp(FAR char *template)
|
||||||
|
|
||||||
/* Count the number of X's at the end of the template */
|
/* Count the number of X's at the end of the template */
|
||||||
|
|
||||||
xptr = strchr(template, 'X');
|
xptr = strchr(path_template, 'X');
|
||||||
if (!xptr)
|
if (!xptr)
|
||||||
{
|
{
|
||||||
/* No Xs? There should always really be 6 */
|
/* No Xs? There should always really be 6 */
|
||||||
|
|
||||||
return open(template, O_RDWR | O_CREAT | O_EXCL, 0666);
|
return open(path_template, O_RDWR | O_CREAT | O_EXCL, 0666);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* There is at least one.. count all of them */
|
/* There is at least one.. count all of them */
|
||||||
|
@ -279,7 +279,7 @@ int mkstemp(FAR char *template)
|
||||||
* directories
|
* directories
|
||||||
*/
|
*/
|
||||||
|
|
||||||
fd = open(template, O_RDWR | O_CREAT | O_EXCL, 0666);
|
fd = open(path_template, O_RDWR | O_CREAT | O_EXCL, 0666);
|
||||||
if (fd >= 0)
|
if (fd >= 0)
|
||||||
{
|
{
|
||||||
/* We have it... return the file descriptor */
|
/* We have it... return the file descriptor */
|
||||||
|
|
|
@ -65,9 +65,9 @@
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
int mktemp(FAR char *template)
|
int mktemp(FAR char *path_template)
|
||||||
{
|
{
|
||||||
int fd = mkstemp(template);
|
int fd = mkstemp(path_template);
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
{
|
{
|
||||||
return ERROR;
|
return ERROR;
|
||||||
|
|
Loading…
Reference in a new issue