for "build" config, import corlib common sources at unix instead (#11989)
[mono-project.git] / support / stdlib.c
blob5c4c57638c9e6ad560129077f56d1eff334cb12e
1 /*
2 * <stdlib.h> wrapper functions.
4 * Authors:
5 * Jonathan Pryor (jonpryor@vt.edu)
7 * Copyright (C) 2004-2005 Jonathan Pryor
8 */
10 #include <stdlib.h>
12 #include "map.h"
13 #include "mph.h"
15 G_BEGIN_DECLS
17 // See Stdlib.cs
18 void*
19 Mono_Unix_VersionString ()
21 return (void *) "MonoProject-2015-12-1";
24 gint32
25 Mono_Posix_Stdlib_EXIT_FAILURE (void)
27 return EXIT_FAILURE;
30 gint32
31 Mono_Posix_Stdlib_EXIT_SUCCESS (void)
33 return EXIT_SUCCESS;
36 gint32
37 Mono_Posix_Stdlib_MB_CUR_MAX (void)
39 return MB_CUR_MAX;
42 gint32
43 Mono_Posix_Stdlib_RAND_MAX (void)
45 return RAND_MAX;
48 void*
49 Mono_Posix_Stdlib_calloc (mph_size_t nmemb, mph_size_t size)
51 if (mph_have_size_t_overflow(nmemb) || mph_have_size_t_overflow(size))
52 return NULL;
54 return calloc ((size_t) nmemb, (size_t) size);
57 void*
58 Mono_Posix_Stdlib_malloc (mph_size_t size)
60 if (mph_have_size_t_overflow(size))
61 return NULL;
63 return malloc ((size_t) size);
66 void*
67 Mono_Posix_Stdlib_realloc (void* ptr, mph_size_t size)
69 if (mph_have_size_t_overflow(size))
70 return NULL;
72 return realloc (ptr, (size_t) size);
75 void
76 Mono_Posix_Stdlib_free (void* p)
78 free (p);
81 G_END_DECLS
84 * vim: noexpandtab