r4m0n

C++ Stack smasher

May 11th, 2017
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. constexpr long positiveElseZero(long value){
  2.     return value > 0 ? value : 0;
  3. }
  4.  
  5. template<long count> __attribute__((always_inline)) inline void nop(){
  6.         nop<positiveElseZero(count - 1)>();
  7.         __asm__ __volatile__("nop\n\t");
  8. }
  9.  
  10. template<> __attribute__((always_inline)) inline void nop<0>(){
  11.     //nothing so the template recursion ends
  12. }
  13.  
  14. void main() {
  15.     nop<2000>();
  16. }
Advertisement
Add Comment
Please, Sign In to add comment