fcontext.h 743 B

12345678910111213141516171819202122232425262728293031
  1. // Copyright Oliver Kowalke 2009.
  2. // Distributed under the Boost Software License, Version 1.0.
  3. // (See accompanying file LICENSE_1_0.txt or copy at
  4. // http://www.boost.org/LICENSE_1_0.txt)
  5. #ifndef BB_FCONTEXT_H
  6. #define BB_FCONTEXT_H
  7. #include <stdlib.h> // size_t
  8. typedef void *fcontext_t;
  9. struct transfer_t{
  10. fcontext_t fcontext;
  11. void *data;
  12. };
  13. extern "C"{
  14. transfer_t jump_fcontext( fcontext_t fcontext,void *vp );
  15. fcontext_t make_fcontext( void *sp,size_t size,void (*func)(transfer_t) );
  16. transfer_t ontop_fcontext( fcontext_t fcontext,void *vp,transfer_t (*func)(transfer_t) );
  17. }
  18. unsigned char *alloc_fcontext_stack( size_t size,bool guard );
  19. void free_fcontext_stack( void *vp,size_t size );
  20. #endif