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

Last change on this file since 477 was 476, checked in by viala@…, 6 years ago

[mini-libc] Add void type to function prototypes with no parameter

File size: 6.4 KB
Line 
1/*
2 * stdlib.h - User level <stdlib> 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/*****************************************************************************************
28 * This file defines the user side <stdlib> library.
29 * Some functions make a system call to access the kernel VFS.
30 * The user/kernel shared structures and mnemonics are defined in
31 * the <syscalls/shared_include/shared_fcntl.h> file.
32 ****************************************************************************************/
33
34#include <shared_stdlib.h>
35
36#define  RAND_MAX       0xFFFF
37
38/*****************************************************************************************
39 * This function terminates a process.
40 *****************************************************************************************
41 * @ status   : terminaison status : 0 / EXIT_SUCCESS / EXIT_FAILURE.
42 ****************************************************************************************/
43void exit( int status );
44
45/*********************************************************************************************
46 * This function translates an ascii character string to an integer value.
47 *********************************************************************************************
48 * @ str   : pointer on charactter string.
49 * @ return an integer value.
50 ********************************************************************************************/
51int atoi(const char * str );
52
53/*********************************************************************************************
54 * This function translates an ascii character string to a float value.
55 *********************************************************************************************
56 * @ str   : pointer on charactter string.
57 * @ return a double value.
58 ********************************************************************************************/
59double atof(const char * str );
60
61/*********************************************************************************************
62 * This function sets the seed for a new sequence of pseudo-random numbers to be returned
63 * by the rand function rand(). These sequences are repeatable by calling srand() with
64 * the same seed value.
65 *********************************************************************************************
66 * # seed  : seed value.
67 ********************************************************************************************/
68void srand( unsigned int seed );
69
70/*********************************************************************************************
71 * This function computes a sequence of pseudo-random integers in the range [0 to RAND_MAX].
72 *********************************************************************************************
73 * @ return an integer value between 0 and RAND_MAX.
74 ********************************************************************************************/
75int rand( void );
76
77/*****************************************************************************************
78 * This function allocates <size> bytes of memory in user space and returns a pointer
79 * on the allocated buffer. The physical memory is allocated from store located in
80 * the calling core cluster.
81 *****************************************************************************************
82 * @ size    : number of requested bytes.
83 * @ returns a pointer on the allocated buffer if success / returns NULL if failure
84 ****************************************************************************************/
85void * malloc( unsigned int size );
86
87/*****************************************************************************************
88 * This function releases the memory buffer identified by the <ptr> argument,
89 * to the store located in the calling core cluster.
90 * It displays an error message, but does nothing if the ptr is illegal.
91 *****************************************************************************************
92 * @ ptr   : pointer on the released buffer.
93 ****************************************************************************************/
94void free( void * ptr );
95
96/*****************************************************************************************
97 * This function releases the memory buffer identified by the <ptr> argument,
98 * to the store located in the calling core cluster, and allocates a new buffer
99 * containing <size> bytes from this store.
100 * The content of the old buffer is copied to the new buffer, up to <size> bytes.
101 * It displays an error message, but does nothing if the ptr is illegal.
102 *****************************************************************************************
103 * @ ptr   : pointer on the released buffer.
104 * @ size  : new buffer requested size (bytes).
105 * @ return a pointer on allocated buffer if success / return NULL if failure
106 ****************************************************************************************/
107void * realloc( void        * ptr,
108                unsigned int  size );
109
110
111/*****************************************************************************************
112 * This function allocates enough space for <count> objects that are <size> bytes
113 * of memory each from the store located in the calling core cluster.
114 * The allocated memory is filled with bytes of value zero.
115 *****************************************************************************************
116 * @ count   : number of requested objects.
117 * @ size    : number of bytes per object.
118 * @ returns a pointer on allocated buffer if success / returns NULL if failure
119 ****************************************************************************************/
120void * calloc( unsigned int count,
121               unsigned int size );
122
123#endif  // _STDLIB_H_
Note: See TracBrowser for help on using the repository browser.