compiler.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*! ----------------------------------------------------------------------------
  2. * @file compiler.h
  3. * @brief
  4. *
  5. * @attention
  6. *
  7. * Copyright 2015 (c) DecaWave Ltd, Dublin, Ireland.
  8. *
  9. * All rights reserved.
  10. *
  11. * @author DecaWave
  12. */
  13. #ifndef COMPILER_H_
  14. #define COMPILER_H_
  15. #ifdef __cplusplus
  16. extern "C" {
  17. #endif
  18. #include <stdio.h>
  19. #include <stddef.h>
  20. #include <stdint.h>
  21. #include <stdlib.h>
  22. #include <string.h>
  23. #include <math.h>
  24. #include <time.h>
  25. #include <assert.h>
  26. #ifdef __GNUC__
  27. #include <unistd.h>
  28. #include <stdbool.h>
  29. #ifndef __cplusplus
  30. #ifndef TRUE
  31. #define TRUE true
  32. #endif
  33. #ifndef FALSE
  34. #define FALSE false
  35. #endif
  36. #endif
  37. #include <sys/stat.h>
  38. #include <sys/time.h>
  39. #include <sys/times.h>
  40. #define Sleep(x) usleep((x*1000))
  41. #define __align4 __attribute__((aligned (4)))
  42. #define __weak __attribute__((weak))
  43. #ifndef __always_inline
  44. #define __always_inline __attribute__((always_inline))
  45. #endif
  46. #endif
  47. #ifdef __ICCARM__
  48. #include <yfuns.h>
  49. #define __caddr_t_required_
  50. #define __useconds_t_required_
  51. #define __tms_struct_required_
  52. #define __stat_struct_required_
  53. #define STDIN_FILENO _LLIO_STDIN
  54. #define STDOUT_FILENO _LLIO_STDOUT
  55. #define STDERR_FILENO _LLIO_STDERR
  56. #define __align4 /* to be defined? */
  57. #define __weak /* to be defined? */
  58. #define _exit __exit
  59. //#define Sleep(x) usleep((x)*1000)
  60. //#include "sleep.h"
  61. #endif
  62. #ifdef _MSC_VER
  63. #include <windows.h>
  64. #include <share.h>
  65. #define __align4 /* no implementation */
  66. #define __weak /* no implementation */
  67. #define __always_inline
  68. #else
  69. #define sprintf_s(x,y,...) 0 // temporary workaround
  70. #endif
  71. #ifndef __IO
  72. #define __IO volatile
  73. #endif
  74. /* Redefine CLOCKS_PER_SEC to make it work with Sleep(1) */
  75. #undef CLOCKS_PER_SEC
  76. #define CLOCKS_PER_SEC 1000
  77. #ifdef __cplusplus
  78. }
  79. #endif
  80. #endif /* COMPILER_H_ */