Giter Club home page Giter Club logo

call_in_stack's Introduction

Welcome to call in stack!

Call a function in a new stack that allocated anywhere. Do not be afraid of stack limit in your coroutines! Try to make your stack shareable between all coroutines!

Attention! It is not a coroutine library, but a library to help your stackful coroutine work more effeicently in memory cost.

#include "call_in_stack.h"
char buffer[4096];
call_in_stack(buffer, &printf, "Hello world!\n");
//Now printf run in buffer as its stack!

Goto https://github.com/yuanzhubi/call_in_stack/wiki/Welcome-to-call_in_stack for details.

Goto QQ Group :293767138(talk_in_stack) for further discussion.


Q:Why it is called "call_in_stack"?

A:It behaves like the impelment of linux system call(the kernel space codes must run in a new stack to avoid user codes know its temporate result saved in memeroy) but it supports more(either the count or the type) arguments and tyep safe. What's more, the X86 Linux kernel uses the name "call_on_stack" while the arm kernel uses "call_with_stack". So we choose "call_in_stack" ^_^!

Q:When it is used?

A:It can be used for function calling that never leads to stackful coroutines switching then the function call do not cost stack of current coroutine. What's more, it is useful for designing a new coroutine library, especially when you want to start a new coroutine(with any type of arguments).


Version 1.0.6: Important adaptive improvement for lower version of GCC!

In this version:

We add support of using call_in_stack in x64 of old GCC version ( tested since GCC 3.4), compiled with no optimization option. (In previous version of call_in_stack, compiling with no optimization option in x64 of old GCC version will fail to complete compile.)


Version 1.0.5: Important adaptive improvement for higher version of GCC!

In this version:

We remove __builtin_unreachable in our library because GCC has different semantic in high version(since 4.5);

We disable the -fipa-sra optimize for "do_call" function (with no performance lost because it is an assemble function indeed) in our library because it breaks the system V ABI and arguments forwarding rule.


Version 1.0.2: Now we support call_in_stack for member function.

std::string a("Hello world"); call_in_stack(printf, "%s\n", call_in_stack(from_member_fun(a, c_str))) ;

And we support call_in_stack for functor or lambda in C++11!

std::string a("Hello world"); call_in_stack_safe(buf, from_functor( [=](int arg){ printf("%s\n", a.c_str()); return arg; } ),2) ;

That means you can write most of your codes of function in a new stack!

call_in_stack's People

Contributors

yuanzhubi avatar

Watchers

square·zheng avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.