mirror of
https://github.com/espressif/openthread.git
synced 2026-09-08 10:10:06 +00:00
spinel: Add mechanism to avoid using errno variable. (#185)
Some platforms do not implement the `errno` variable. This change
allows Spinel to work properly on those platforms.
To allow Spinel to build on those platforms, build Spinel with
the following command line argument:
-DSPINEL_PLATFORM_DOESNT_IMPLEMENT_ERRNO_VAR=1
This commit is contained in:
committed by
Jonathan Hui
parent
676fa4f860
commit
089a365b55
+11
-1
@@ -48,12 +48,22 @@
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// MARK: -
|
||||
|
||||
#if defined(errno) && SPINEL_PLATFORM_DOESNT_IMPLEMENT_ERRNO_VAR
|
||||
#error SPINEL_PLATFORM_DOESNT_IMPLEMENT_ERRNO_VAR is set but errno is already defined.
|
||||
#endif
|
||||
|
||||
// Work-around for platforms that don't implement the `errno` variable.
|
||||
#if !defined(errno) && SPINEL_PLATFORM_DOESNT_IMPLEMENT_ERRNO_VAR
|
||||
static int spinel_errno_workaround_;
|
||||
#define errno spinel_errno_workaround_
|
||||
#endif // SPINEL_PLATFORM_DOESNT_IMPLEMENT_ERRNO_VAR
|
||||
|
||||
#ifndef assert_printf
|
||||
#define assert_printf(fmt, ...) \
|
||||
fprintf(stderr, \
|
||||
|
||||
Reference in New Issue
Block a user