File tree Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Original file line number Diff line number Diff line change 1+ /*
2+ * errno.c
3+ *
4+ * Created on: 1 Oct 2022
5+ * Author: David
6+ *
7+ * This file replaces the one in newlib in order to avoid pulling the reent struct
8+ */
9+
10+ static int globalErrno = 0 ;
11+
12+ int * __errno () noexcept
13+ {
14+ return & globalErrno ;
15+ }
16+
17+ // End
Original file line number Diff line number Diff line change 3232 * Interface documentation refer to malloc.c.
3333 */
3434
35+ #if 0 // DC we don't want to pull in stdio
3536#include <stdio.h>
37+ #endif
3638#include <string.h>
39+ #if 0 // DC we don't want to pull in errno because it pulls in the reent struct
3740#include <errno.h>
41+ #endif
3842#include <malloc.h>
3943
4044#if 1 // DC
5761#include <assert.h>
5862#else
5963#define assert (x ) ((void)0)
64+ #include <stdint.h>
6065extern void vAssertCalled (uint32_t line , const char * file ) noexcept ;
6166#endif
6267
@@ -116,9 +121,9 @@ extern void ReleaseMallocMutex();
116121#else
117122#define MALLOC_LOCK
118123#define MALLOC_UNLOCK
119- #endif
120124
121125#define RERRNO errno
126+ #endif
122127
123128#define nano_malloc malloc
124129#define nano_free free
@@ -279,7 +284,9 @@ void * nano_malloc(RARG malloc_size_t s)
279284
280285 if (alloc_size >= MAX_ALLOC_SIZE || alloc_size < s )
281286 {
287+ #if 0 // DC
282288 RERRNO = ENOMEM ;
289+ #endif
283290 return NULL ;
284291 }
285292
@@ -328,7 +335,9 @@ void * nano_malloc(RARG malloc_size_t s)
328335 /* sbrk returns -1 if fail to allocate */
329336 if (r == (void * )-1 )
330337 {
338+ #if 0 // DC
331339 RERRNO = ENOMEM ;
340+ #endif
332341 MALLOC_UNLOCK ;
333342 return NULL ;
334343 }
You can’t perform that action at this time.
0 commit comments