2012-02-03 06:08:17 -05:00
|
|
|
/*
|
2013-11-09 09:27:32 -05:00
|
|
|
* MiSoC
|
2012-02-03 06:08:17 -05:00
|
|
|
* Copyright (C) 2007, 2008, 2009, 2011 Sebastien Bourdeauducq
|
|
|
|
* Copyright (C) Linux kernel developers
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, version 3 of the License.
|
|
|
|
*
|
|
|
|
* This program 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 General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __STDLIB_H
|
|
|
|
#define __STDLIB_H
|
|
|
|
|
2012-05-25 16:30:17 -04:00
|
|
|
#include <stddef.h>
|
|
|
|
|
2013-03-25 09:38:58 -04:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2012-02-03 06:08:17 -05:00
|
|
|
#define PRINTF_ZEROPAD 1 /* pad with zero */
|
|
|
|
#define PRINTF_SIGN 2 /* unsigned/signed long */
|
|
|
|
#define PRINTF_PLUS 4 /* show plus */
|
|
|
|
#define PRINTF_SPACE 8 /* space if plus */
|
|
|
|
#define PRINTF_LEFT 16 /* left justified */
|
|
|
|
#define PRINTF_SPECIAL 32 /* 0x */
|
|
|
|
#define PRINTF_LARGE 64 /* use 'ABCDEF' instead of 'abcdef' */
|
|
|
|
|
|
|
|
#define likely(x) x
|
|
|
|
#define unlikely(x) x
|
|
|
|
|
2012-06-04 13:41:49 -04:00
|
|
|
static inline int abs(int x)
|
|
|
|
{
|
|
|
|
return x > 0 ? x : -x;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline long int labs(long int x)
|
|
|
|
{
|
|
|
|
return x > 0 ? x : -x;
|
|
|
|
}
|
2012-02-03 06:08:17 -05:00
|
|
|
|
|
|
|
unsigned long strtoul(const char *nptr, char **endptr, int base);
|
2013-05-31 08:44:52 -04:00
|
|
|
long strtol(const char *nptr, char **endptr, int base);
|
|
|
|
double strtod(const char *str, char **endptr);
|
|
|
|
|
2012-02-03 06:08:17 -05:00
|
|
|
int skip_atoi(const char **s);
|
|
|
|
static inline int atoi(const char *nptr) {
|
2013-05-31 08:44:52 -04:00
|
|
|
return strtol(nptr, NULL, 10);
|
2012-02-03 06:08:17 -05:00
|
|
|
}
|
|
|
|
static inline long atol(const char *nptr) {
|
|
|
|
return (long)atoi(nptr);
|
|
|
|
}
|
|
|
|
char *number(char *buf, char *end, unsigned long num, int base, int size, int precision, int type);
|
|
|
|
|
2012-05-25 12:57:23 -04:00
|
|
|
#define RAND_MAX 2147483647
|
|
|
|
|
2012-02-03 06:08:17 -05:00
|
|
|
unsigned int rand(void);
|
2012-05-25 12:57:23 -04:00
|
|
|
void srand(unsigned int seed);
|
2015-07-26 05:43:22 -04:00
|
|
|
void abort(void) __attribute__((noreturn));
|
2012-02-03 06:08:17 -05:00
|
|
|
|
2012-06-04 13:45:13 -04:00
|
|
|
void qsort(void *base, size_t nmemb, size_t size, int(*compar)(const void *, const void *));
|
|
|
|
|
2012-05-25 16:50:30 -04:00
|
|
|
/*
|
|
|
|
* The following functions are not provided by this library.
|
|
|
|
*/
|
|
|
|
|
|
|
|
char *getenv(const char *name);
|
|
|
|
|
2012-05-28 11:20:06 -04:00
|
|
|
void *malloc(size_t size);
|
|
|
|
void free(void *ptr);
|
|
|
|
void *realloc(void *ptr, size_t size);
|
|
|
|
|
2013-03-25 09:38:58 -04:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-02-03 06:08:17 -05:00
|
|
|
#endif /* __STDLIB_H */
|