source: trunk/libs/mini-libc/stdlib.h @ 444

Last change on this file since 444 was 444, checked in by satin@…, 6 years ago

add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc

File size: 5.7 KB
Line 
1/*
2 * stdlib.h - User level library definition.
3 *
4 * Author     Alain Greiner (2016,2017)
5 *
6 * Copyright (c) UPMC Sorbonne Universites
7 *
8 * This file is part of ALMOS-MKH.
9 *
10 * ALMOS-MKH is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; version 2.0 of the License.
13 *
14 * ALMOS-MKH is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with ALMOS-MKH; if not, write to the Free Software Foundation,
21 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 */
23
24#ifndef _STDLIB_H_
25#define _STDLIB_H
26
27#include <almos-mkh/stdlib.h>
28
29/*****************************************************************************************
30 * This function terminates a process.
31 *****************************************************************************************
32 * @ status   : terminaison status : 0 / EXIT_SUCCESS / EXIT_FAILURE.
33 ****************************************************************************************/
34void exit( int status );
35
36
37/*********************************************************************************************
38 * This function TODO
39 *********************************************************************************************
40 ********************************************************************************************/
41int atoi(const char *str);
42
43/*********************************************************************************************
44 * This function TODO
45 *********************************************************************************************
46 ********************************************************************************************/
47double atof(const char *str);
48
49/*********************************************************************************************
50 * This function sets the seed for a new sequence of pseudo-random numbers to be returned
51 * by the rand function rand(). These sequences are repeatable by calling srand() with
52 * the same seed value.
53 *********************************************************************************************
54 * # seed  : seed value.
55 ********************************************************************************************/
56void srand( unsigned int seed );
57
58/*********************************************************************************************
59 * This function computes a sequence of pseudo-random integers in the range [0 to RAND_MAX].
60 *********************************************************************************************
61 * @ return an integer value between 0 and RAND_MAX.
62 ********************************************************************************************/
63int rand();
64
65/*****************************************************************************************
66 * This function allocates <size> bytes of memory in user space and returns a pointer
67 * on the allocated buffer. The physical memory is allocated from store located in
68 * the calling core cluster.
69 *****************************************************************************************
70 * @ size    : number of requested bytes.
71 * @ returns a pointer on the allocated buffer if success / returns NULL if failure
72 ****************************************************************************************/
73void * malloc( unsigned int size );
74
75
76/*****************************************************************************************
77 * This function releases the memory buffer identified by the <ptr> argument,
78 * to the store located in the calling core cluster.
79 * It displays an error message, but does nothing if the ptr is illegal.
80 *****************************************************************************************
81 * @ ptr   : pointer on the released buffer.
82 ****************************************************************************************/
83void free( void * ptr );
84
85/*****************************************************************************************
86 * This function releases the memory buffer identified by the <ptr> argument,
87 * to the store located in the calling core cluster, and allocates a new buffer
88 * containing <size> bytes from this store.
89 * The content of the old buffer is copied to the new buffer, up to <size> bytes.
90 * It displays an error message, but does nothing if the ptr is illegal.
91 *****************************************************************************************
92 * @ ptr   : pointer on the released buffer.
93 * @ size  : new buffer requested size (bytes).
94 * @ return a pointer on allocated buffer if success / return NULL if failure
95 ****************************************************************************************/
96void * realloc( void        * ptr,
97                unsigned int  size );
98
99
100/*****************************************************************************************
101 * This function allocates enough space for <count> objects that are <size> bytes
102 * of memory each from the store located in the calling core cluster.
103 * The allocated memory is filled with bytes of value zero.
104 *****************************************************************************************
105 * @ count   : number of requested objects.
106 * @ size    : number of bytes per object.
107 * @ returns a pointer on allocated buffer if success / returns NULL if failure
108 ****************************************************************************************/
109void * calloc( unsigned int count,
110               unsigned int size );
111#endif  // _STDLIB_H_
Note: See TracBrowser for help on using the repository browser.