File: stdlib.h

package info (click to toggle)
avr-libc 20020203-2
  • links: PTS
  • area: main
  • in suites: woody
  • size: 1,448 kB
  • ctags: 6,562
  • sloc: ansic: 7,631; asm: 4,424; sh: 2,703; makefile: 338; pascal: 289
file content (127 lines) | stat: -rw-r--r-- 2,907 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#ifndef _STDLIB_H_
#define	_STDLIB_H_ 1

#define __need_NULL
#define __need_size_t
#define __need_wchar_t
#include <stddef.h>

#ifndef __ptr_t
#define __ptr_t void *
#endif

#ifdef __cplusplus
extern "C" {
#endif

typedef struct {
	int quot;
	int rem;
} div_t;

typedef struct {
	long quot;
	long rem;
} ldiv_t;

typedef int (*__compar_fn_t)(const void *, const void *);

#define	RAND_MAX 0x7FFFFFFF

#ifndef __ATTR_CONST__
#define __ATTR_CONST__ __attribute__((__const__))
#endif

#ifndef __ATTR_MALLOC__
#define __ATTR_MALLOC__ __attribute__((__malloc__))
#endif

#ifndef __ATTR_NORETURN__
#define __ATTR_NORETURN__ __attribute__((__noreturn__))
#endif

#ifndef __ATTR_PURE__
#define __ATTR_PURE__ __attribute__((__pure__))
#endif

extern __inline__ void abort(void) __ATTR_NORETURN__;
extern __inline__ void
abort(void)
{
	for (;;);
}

extern __inline__ int abs(int __x) __ATTR_CONST__;
extern __inline__ int
abs(int __x)
{
	return (__x < 0) ? -__x : __x;
}

extern __inline__ long labs(long __x) __ATTR_CONST__;
extern __inline__ long
labs(long __x)
{
	return (__x < 0) ? -__x : __x;
}

extern void *bsearch(const void *, const void *, size_t, size_t,
	int (*)(const void *, const void *));

/* __divmodhi4 and __divmodsi4 from libgcc.a */
extern div_t div(int, int) __asm__("__divmodhi4") __ATTR_CONST__;
extern ldiv_t ldiv(long, long) __asm__("__divmodsi4") __ATTR_CONST__;

extern void qsort(void *, size_t, size_t, __compar_fn_t);

extern long strtol(const char *, char **, int);
extern unsigned long strtoul(const char *, char **, int);

extern __inline__ long atol(const char *) __ATTR_PURE__;
extern __inline__ long
atol(const char *__p)
{
	return strtol(__p, (char **) 0, 10);
}

#if 0
extern __inline__ int atoi(const char *__p) __ATTR_PURE__;
extern __inline__ int
atoi(const char *__p)
{
	return (int) atol(__p);
}
#else
/* optimized asm version, much smaller if strtol() not used elsewhere */
extern int atoi(const char *) __ATTR_PURE__;
#endif

extern void exit(int) __ATTR_NORETURN__;

/* implemented but not tested */
extern void *malloc(size_t) __ATTR_MALLOC__;
extern void free(void *);
extern double strtod(const char *, char **);

/* non-standard (i.e. non-ANSI C) functions */
extern char *itoa(int __val, char *__s, int __radix);
extern char *ltoa(long int __val, char *__s, int __radix);
extern char *utoa(unsigned int __val, char *__s, int __radix);
extern char *ultoa(unsigned long int __val, char *__s, int __radix);
extern char *dtostre(double __val, char *__s, unsigned char __ndig, unsigned char __flags);
extern char *dtostrf(double __val, char __width, char __prec, char *__s);

#if 0  /* not yet implemented */
extern int atexit(void (*)(void));
extern double atof(const char *);
extern void *calloc(size_t, size_t);
extern int rand(void);
extern void *realloc(void *, size_t);
extern void srand(unsigned int);
#endif

#ifdef __cplusplus
}
#endif

#endif /* _STDLIB_H_ */