mirror of
				https://github.com/esp8266/Arduino.git
				synced 2025-10-30 04:26:50 +03:00 
			
		
		
		
	* Use newlib libc library This change adds libcmin.a, which is created from newlib libc by selectively removing some of the object files (mostly related to heap management). The list of files is available in tools/sdk/lib/make_libcmin.sh. Files which are not needed are commented out. This change adds support for various functions which were missing, like sscanf, strftime, etc. * Fix some of the time functions * Redirect stdout to serial * Implement __putc_r * Switch to custom newlib build Built from https://github.com/igrr/newlib-xtensa using: ./configure --with-newlib --enable-multilib --disable-newlib-io-c99-formats --enable-newlib-supplied-syscalls --enable-target-optspace --program-transform-name="s&^&xtensa-lx106-elf-&" --disable-option-checking --with-target-subdir=xtensa-lx106-elf --target=xtensa-lx106-elf --enable-newlib-nano-formatted-io --enable-newlib-reent-small --prefix=path-to-arduino-core/tools/sdk/libc CROSS_CFLAGS="-DMALLOC_PROVIDED -DSIGNAL_PROVIDED -DABORT_PROVIDED" make make install * Update tests
		
			
				
	
	
		
			92 lines
		
	
	
		
			2.6 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			92 lines
		
	
	
		
			2.6 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
| /* time.h -- An implementation of the standard Unix <sys/time.h> file.
 | |
|    Written by Geoffrey Noer <noer@cygnus.com>
 | |
|    Public domain; no rights reserved. */
 | |
| 
 | |
| #ifndef _SYS_TIME_H_
 | |
| #define _SYS_TIME_H_
 | |
| 
 | |
| #include <_ansi.h>
 | |
| #include <sys/types.h>
 | |
| 
 | |
| #ifdef __cplusplus
 | |
| extern "C" {
 | |
| #endif
 | |
| 
 | |
| #ifndef _TIMEVAL_DEFINED
 | |
| #define _TIMEVAL_DEFINED
 | |
| struct timeval {
 | |
|   time_t      tv_sec;
 | |
|   suseconds_t tv_usec;
 | |
| };
 | |
| 
 | |
| /* BSD time macros used by RTEMS code */
 | |
| #if defined (__rtems__) || defined (__CYGWIN__)
 | |
| 
 | |
| /* Convenience macros for operations on timevals.
 | |
|    NOTE: `timercmp' does not work for >= or <=.  */
 | |
| #define	timerisset(tvp)		((tvp)->tv_sec || (tvp)->tv_usec)
 | |
| #define	timerclear(tvp)		((tvp)->tv_sec = (tvp)->tv_usec = 0)
 | |
| #define	timercmp(a, b, CMP) 						      \
 | |
|   (((a)->tv_sec == (b)->tv_sec) ? 					      \
 | |
|    ((a)->tv_usec CMP (b)->tv_usec) : 					      \
 | |
|    ((a)->tv_sec CMP (b)->tv_sec))
 | |
| #define	timeradd(a, b, result)						      \
 | |
|   do {									      \
 | |
|     (result)->tv_sec = (a)->tv_sec + (b)->tv_sec;			      \
 | |
|     (result)->tv_usec = (a)->tv_usec + (b)->tv_usec;			      \
 | |
|     if ((result)->tv_usec >= 1000000)					      \
 | |
|       {									      \
 | |
| 	++(result)->tv_sec;						      \
 | |
| 	(result)->tv_usec -= 1000000;					      \
 | |
|       }									      \
 | |
|   } while (0)
 | |
| #define	timersub(a, b, result)						      \
 | |
|   do {									      \
 | |
|     (result)->tv_sec = (a)->tv_sec - (b)->tv_sec;			      \
 | |
|     (result)->tv_usec = (a)->tv_usec - (b)->tv_usec;			      \
 | |
|     if ((result)->tv_usec < 0) {					      \
 | |
|       --(result)->tv_sec;						      \
 | |
|       (result)->tv_usec += 1000000;					      \
 | |
|     }									      \
 | |
|   } while (0)
 | |
| #endif /* defined (__rtems__) || defined (__CYGWIN__) */
 | |
| #endif /* !_TIMEVAL_DEFINED */
 | |
| 
 | |
| struct timezone {
 | |
|   int tz_minuteswest;
 | |
|   int tz_dsttime;
 | |
| };
 | |
| 
 | |
| #ifdef __CYGWIN__
 | |
| #include <cygwin/sys_time.h>
 | |
| #endif /* __CYGWIN__ */
 | |
| 
 | |
| #define ITIMER_REAL     0
 | |
| #define ITIMER_VIRTUAL  1
 | |
| #define ITIMER_PROF     2
 | |
| 
 | |
| struct  itimerval {
 | |
|   struct  timeval it_interval;
 | |
|   struct  timeval it_value;
 | |
| };
 | |
| 
 | |
| #ifdef _COMPILING_NEWLIB
 | |
| int _EXFUN(_gettimeofday, (struct timeval *__p, void *__tz));
 | |
| #endif
 | |
| 
 | |
| int _EXFUN(gettimeofday, (struct timeval *__restrict __p,
 | |
| 			  void *__restrict __tz));
 | |
| #if __BSD_VISIBLE
 | |
| int _EXFUN(settimeofday, (const struct timeval *, const struct timezone *));
 | |
| int _EXFUN(adjtime, (const struct timeval *, struct timeval *));
 | |
| #endif
 | |
| int _EXFUN(utimes, (const char *__path, const struct timeval *__tvp));
 | |
| int _EXFUN(getitimer, (int __which, struct itimerval *__value));
 | |
| int _EXFUN(setitimer, (int __which, const struct itimerval *__restrict __value,
 | |
| 					struct itimerval *__restrict __ovalue));
 | |
| 
 | |
| #ifdef __cplusplus
 | |
| }
 | |
| #endif
 | |
| #endif /* _SYS_TIME_H_ */
 |