misc.h 819 B

1234567891011121314151617181920
  1. // This file is Copyright (c) 2023-2025 Victor Suarez Rovere <suarezvictor@gmail.com>
  2. // SPDX-License-Identifier: AGPL-3.0-only
  3. #ifndef __MISC_H__
  4. #define __MISC_H__
  5. #ifndef DISABLE_HARDWARE_ACCEL
  6. #include <generated/csr.h>
  7. #ifdef CSR_TIMER0_UPTIME_CYCLES_ADDR
  8. static inline uint64_t highres_ticks(void) { timer0_uptime_latch_write(1); return timer0_uptime_cycles_read(); }
  9. static inline uint64_t highres_ticks_freq(void) { return CONFIG_CLOCK_FREQUENCY; }
  10. #endif
  11. #endif
  12. #define ACCEL_STATIC_ASSERT(cond, msg) typedef char static_assertion_##msg[(cond)?1:-1];
  13. //#define ACCEL_STATIC_ASSERT(cond, msg) _Static_assert(cond, msg);
  14. //#define ACCEL_STATIC_ASSERT(X, msg) ({ extern int __attribute__((error("assertion failure: '" #X ##msg))) compile_time_check(); ((X)?0:compile_time_check()),0; })
  15. #endif // __MISC_H__