Mercurial > nand-ecoscentric
annotate packages/language/c/libc/current/include/stdlib.h @ 66:bf00f99aec69 ecos-sw-2000-02-02
Merge from eCos master repository on 2000-02-02-19:16:44-GMT
| author | jlarmour |
|---|---|
| date | Wed, 02 Feb 2000 19:57:02 +0000 |
| parents | c38311975d4f |
| children |
| rev | line source |
|---|---|
| 0 | 1 #ifndef CYGONCE_LIBC_STDLIB_H |
| 2 #define CYGONCE_LIBC_STDLIB_H | |
| 3 //======================================================================== | |
| 4 // | |
| 5 // stdlib.h | |
| 6 // | |
| 7 // ISO C standard utility functions (ISO C standard section 7.10) | |
| 8 // | |
| 9 //======================================================================== | |
| 10 //####COPYRIGHTBEGIN#### | |
|
64
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
11 // |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
12 // ------------------------------------------- |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
13 // The contents of this file are subject to the Red Hat eCos Public License |
|
66
bf00f99aec69
Merge from eCos master repository on 2000-02-02-19:16:44-GMT
jlarmour
parents:
64
diff
changeset
|
14 // Version 1.1 (the "License"); you may not use this file except in |
|
64
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
15 // compliance with the License. You may obtain a copy of the License at |
|
66
bf00f99aec69
Merge from eCos master repository on 2000-02-02-19:16:44-GMT
jlarmour
parents:
64
diff
changeset
|
16 // http://www.redhat.com/ |
|
64
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
17 // |
|
66
bf00f99aec69
Merge from eCos master repository on 2000-02-02-19:16:44-GMT
jlarmour
parents:
64
diff
changeset
|
18 // Software distributed under the License is distributed on an "AS IS" |
|
64
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
19 // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
20 // License for the specific language governing rights and limitations under |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
21 // the License. |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
22 // |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
23 // The Original Code is eCos - Embedded Configurable Operating System, |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
24 // released September 30, 1998. |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
25 // |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
26 // The Initial Developer of the Original Code is Red Hat. |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
27 // Portions created by Red Hat are |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
28 // Copyright (C) 1998, 1999, 2000 Red Hat, Inc. |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
29 // All Rights Reserved. |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
30 // ------------------------------------------- |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
31 // |
| 0 | 32 //####COPYRIGHTEND#### |
| 33 //======================================================================== | |
| 34 //#####DESCRIPTIONBEGIN#### | |
| 35 // | |
| 2 | 36 // Author(s): jlarmour |
| 37 // Contributors: jlarmour | |
| 38 // Date: 1999-03-17 | |
| 0 | 39 // Purpose: |
| 40 // Description: | |
| 2 | 41 // Usage: #include <stdlib.h> |
| 0 | 42 // |
| 43 //####DESCRIPTIONEND#### | |
| 44 // | |
| 45 //======================================================================== | |
| 46 | |
| 47 // CONFIGURATION | |
| 48 | |
| 49 #include <pkgconf/libc.h> // Configuration header | |
| 50 | |
| 51 // INCLUDES | |
| 52 | |
| 53 #include <cyg/infra/cyg_type.h> // Common type definitions and support | |
| 54 #include <stddef.h> // NULL, wchar_t and size_t from compiler | |
| 55 #include <limits.h> // for INT_MAX definition used below | |
| 56 | |
| 57 // CONSTANTS | |
| 58 | |
| 2 | 59 // as described in ISO para 7.10 |
| 0 | 60 |
| 61 // codes to pass to exit() | |
| 62 | |
| 2 | 63 // Successful exit status - must be zero (POSIX 1003.1 8.1) |
| 64 #define EXIT_SUCCESS 0 | |
| 65 // Failing exit status - must be non-zero (POSIX 1003.1 8.1) | |
| 66 #define EXIT_FAILURE 1 | |
| 0 | 67 |
| 68 // Maximum value returned by rand() | |
| 69 | |
| 70 #define RAND_MAX INT_MAX | |
| 71 | |
| 72 | |
| 73 // Maximum number of bytes in a multibyte character for the current locale | |
| 74 | |
| 75 #define MB_CUR_MAX 1 | |
| 76 | |
| 77 | |
| 78 // TYPE DEFINITIONS | |
| 79 | |
| 80 // as described in ANSI para 7.10 | |
| 81 | |
| 82 // return type of the div() function | |
| 83 | |
| 84 typedef struct { | |
| 85 int quot; // quotient | |
| 86 int rem; // remainder | |
| 87 } div_t; | |
| 88 | |
| 89 | |
| 90 // return type of the ldiv() function | |
| 91 | |
| 92 typedef struct { | |
| 93 long quot; // quotient | |
| 94 long rem; // remainder | |
| 95 } ldiv_t; | |
| 96 | |
| 97 // Unofficial type of comparison function used by both bsearch() and | |
| 98 // qsort() | |
| 99 | |
| 100 typedef int (*Cyg_comparison_fn_t)(const void * /* object1 */, | |
| 101 const void * /* object2 */); | |
| 102 | |
| 103 // Similarly, type of function used by atexit() | |
| 2 | 104 typedef void (*Cyg_libc_atexit_fn_t)( void ); |
| 0 | 105 |
| 106 | |
| 107 // FUNCTION PROTOTYPES | |
| 108 | |
| 109 //======================================================================== | |
| 110 | |
| 111 // 7.10.1 String conversion functions | |
| 112 | |
| 113 externC double | |
| 114 atof( const char * /* double_str */ ); | |
| 115 | |
| 116 externC int | |
| 117 atoi( const char * /* int_str */ ); | |
| 118 | |
| 119 externC long | |
| 120 atol( const char * /* long_str */ ); | |
| 121 | |
| 122 externC double | |
| 123 strtod( const char * /* double_str */, char ** /* endptr */ ); | |
| 124 | |
| 125 externC long | |
| 126 strtol( const char * /* long_str */, char ** /* endptr */, | |
| 127 int /* base */ ); | |
| 128 | |
| 129 externC unsigned long | |
| 130 strtoul( const char * /* ulong_str */, char ** /* endptr */, | |
| 131 int /* base */ ); | |
| 132 | |
| 133 //======================================================================== | |
| 134 | |
| 135 // 7.10.2 Pseudo-random sequence generation functions | |
| 136 | |
| 137 externC int | |
| 138 rand( void ); | |
| 139 | |
| 140 externC void | |
| 141 srand( unsigned int /* seed */ ); | |
| 142 | |
| 143 // POSIX 1003.1 section 8.3.8 rand_r() | |
| 144 externC int | |
| 145 rand_r( unsigned int * /* seed */ ); | |
| 146 | |
| 147 //======================================================================== | |
| 148 | |
| 149 // 7.10.3 Memory management functions | |
| 150 | |
| 151 #ifdef CYGPKG_LIBC_MALLOC | |
| 152 | |
| 153 externC void * | |
| 154 calloc( size_t /* num_objects */, size_t /* object_size */ ); | |
| 155 | |
| 156 externC void | |
| 157 free( void * /* ptr */ ); | |
| 158 | |
| 159 externC void * | |
| 160 malloc( size_t /* size */ ); | |
| 161 | |
| 162 externC void * | |
| 163 realloc( void * /* ptr */, size_t /* size */ ); | |
| 164 | |
| 165 #endif // ifdef CYGPKG_LIBC_MALLOC | |
| 166 | |
| 167 //======================================================================== | |
| 168 | |
| 169 // 7.10.4 Communication with the environment | |
| 170 | |
| 171 externC void | |
| 2 | 172 abort( void ) CYGBLD_ATTRIB_NORET; |
| 0 | 173 |
| 174 externC int | |
| 2 | 175 atexit( Cyg_libc_atexit_fn_t /* func_to_register */ ); |
| 0 | 176 |
| 177 externC void | |
| 2 | 178 exit( int /* status */ ) CYGBLD_ATTRIB_NORET; |
| 0 | 179 |
| 180 /* POSIX 1003.1 section 3.2.2 "Terminate a process" */ | |
| 181 | |
| 182 externC void | |
| 2 | 183 _exit( int /* status */ ) CYGBLD_ATTRIB_NORET; |
| 0 | 184 |
| 185 externC char * | |
| 186 getenv( const char * /* name */ ); | |
| 187 | |
| 2 | 188 externC int |
| 189 system( const char * /* command */ ); | |
| 190 | |
| 0 | 191 |
| 192 //======================================================================== | |
| 193 | |
| 194 // 7.10.5 Searching and sorting utilities | |
| 195 | |
| 196 externC void * | |
| 197 bsearch( const void * /* search_key */, const void * /* first_object */, | |
| 198 size_t /* num_objects */, size_t /* object_size */, | |
| 199 Cyg_comparison_fn_t /* comparison_fn */ ); | |
| 200 | |
| 201 externC void | |
| 202 qsort( void * /* first_object */, size_t /* num_objects */, | |
| 203 size_t /* object_size */, Cyg_comparison_fn_t /* comparison_fn */ ); | |
| 204 | |
| 205 | |
| 206 //======================================================================== | |
| 207 | |
| 208 // 7.10.6 Integer arithmetic functions | |
| 209 | |
| 210 externC int | |
| 2 | 211 abs( int /* val */ ) CYGBLD_ATTRIB_CONST; |
| 0 | 212 |
| 213 externC div_t | |
| 2 | 214 div( int /* numerator */, int /* denominator */ ) CYGBLD_ATTRIB_CONST; |
| 0 | 215 |
| 216 externC long | |
| 2 | 217 labs( long /* val */ ) CYGBLD_ATTRIB_CONST; |
| 0 | 218 |
| 219 externC ldiv_t | |
| 2 | 220 ldiv( long /* numerator */, long /* denominator */ ) CYGBLD_ATTRIB_CONST; |
| 0 | 221 |
| 222 //======================================================================== | |
| 223 | |
| 2 | 224 // NON-STANDARD FUNCTIONS |
| 225 | |
| 226 ///////////////////// | |
| 227 // cyg_libc_itoa() // | |
| 228 ///////////////////// | |
| 229 // | |
| 230 // This converts num to a string and puts it into s padding with | |
| 231 // "0"'s if padzero is set, or spaces otherwise if necessary. | |
| 232 // The number of chars written to s is returned | |
| 233 // | |
| 234 | |
| 235 externC cyg_uint8 | |
| 236 cyg_libc_itoa( cyg_uint8 *__s, cyg_int32 __num, cyg_uint8 __width, | |
| 237 cyg_bool __padzero ); | |
| 238 | |
| 239 //======================================================================== | |
| 240 | |
| 241 | |
| 0 | 242 // INLINE FUNCTIONS |
| 243 | |
| 244 #ifdef CYGIMP_LIBC_STDLIB_INLINES | |
| 245 #include <stdlib.inl> | |
| 246 #endif | |
| 247 | |
| 248 #endif // CYGONCE_LIBC_STDLIB_H multiple inclusion protection | |
| 249 | |
| 250 // EOF stdlib.h |
