################################################################################
# Newlib/libc code -- reent
################################################################################
+ifeq ($(CONFIG_HAVE_SCHED),y)
+# if scheduling enabled, then Unikraft provides __getreent()
+LIBNEWLIBC_CFLAGS-y += -D__DYNAMIC_REENT__
+else
+LIBNEWLIBC_SRCS-y += $(LIBNEWLIB_LIBC)/reent/getreent.c
+endif
LIBNEWLIBC_SRCS-y += $(LIBNEWLIB_LIBC)/reent/closer.c
LIBNEWLIBC_SRCS-y += $(LIBNEWLIB_LIBC)/reent/reent.c
LIBNEWLIBC_SRCS-y += $(LIBNEWLIB_LIBC)/reent/impure.c
LIBNEWLIBC_SRCS-y += $(LIBNEWLIB_LIBC)/reent/fcntlr.c
LIBNEWLIBC_SRCS-y += $(LIBNEWLIB_LIBC)/reent/fstatr.c
-LIBNEWLIBC_SRCS-y += $(LIBNEWLIB_LIBC)/reent/getreent.c
LIBNEWLIBC_SRCS-y += $(LIBNEWLIB_LIBC)/reent/gettimeofdayr.c
LIBNEWLIBC_SRCS-y += $(LIBNEWLIB_LIBC)/reent/isattyr.c
LIBNEWLIBC_SRCS-y += $(LIBNEWLIB_LIBC)/reent/linkr.c
/* A definition only for this header */
#define __undef_rtems__NEWLIBGLUE_TIME_H
#define __rtems__
-#endif
+
+/*
+ * __DYNAMIC_REENT__ is defined in sys/config.h if
+ * __rtems__ is defined; we undefine it in order to
+ * avoid warnings.
+ */
+#ifdef __DYNAMIC_REENT__
+#define __define_DYNAMIC_REENT__NEWLIBGLUE_TIME_H
+#undef __DYNAMIC_REENT__
+#endif /* __DYNAMIC_REENT__ */
+#endif /* __rtems__ */
#include_next <time.h>
#undef __undef_rtems__NEWLIBGLUE_TIME_H
#endif
+#ifdef __define_DYNAMIC_REENT__NEWLIBGLUE_TIME_H
+#define __DYNAMIC_REENT__
+#undef __define_DYNAMIC_REENT__NEWLIBGLUE_TIME_H
+#endif
+
#endif /* NEWLIBGLUE_TIME_H */