Sponsored Content
Full Discussion: C function call dynamically
Top Forums Programming C function call dynamically Post 302379389 by jim mcnamara on Thursday 10th of December 2009 02:43:49 PM
Old 12-10-2009
Dream Warrior - consider trampolines or indirect function calls found most often in callbacks. I think python uses trampolines to support coroutines. ghostdog would know for sure.

Linux trampoline code is described in great detail in: 'Understanding the Linux Kernel' by Daniel P. Bovet and Marco Cesati.

gcc documentation:
Trampolines - GNU Compiler Collection (GCC) Internals



The lazy man's version -
A trampoline is small code segment, usually a vector, created at run time. It normally lives on the stack, in the stack frame of the 'holding' function.

For mixing pieces of code with incompatible calling conventions, trampolines can convert the caller's convention to the callee's convention. For example, C code that needs to call C++ objects can have a trampoline to change calling conventions.

gcc implements trampolines as nested functions.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

function call

can I call a function in bash script just as in C++ while do function() done function() thanks, Steffen (3 Replies)
Discussion started by: forever_49ers
3 Replies

2. Programming

Help with a function call

Hi, Can anyone help me figure out the problem I'm having with a function call? I have a header file, which sets an enum: typedef enum {INFO, WARNING, FATAL} Levels; int log_event (Levels, char *fmt, ...); ..then the function is called this way: log_event(INFO, "Message text"); ... (6 Replies)
Discussion started by: Stevhp
6 Replies

3. Shell Programming and Scripting

call function

I have a function check_ok in my abc.sh. which return me 1 or 0 . I want to call this fuction through other shell script. this shell also send two parameter to calling function. Can you please tell me how. I am very new in unix. #!/bin/bash date_equal() { sqlplus -silent... (4 Replies)
Discussion started by: Jamil Qadir
4 Replies

4. Shell Programming and Scripting

help on function call

hello, when i call function inside awk traitement it doesn't work, i don't have error execution but i don't get result and if i call the function outside awk traitement it work well.. there's something special in awk call function?? here is the example : awk -F "," '{ {first=$1; sec=$2;... (3 Replies)
Discussion started by: kamel.seg
3 Replies

5. Shell Programming and Scripting

Function Call

How we can start a process if doesn't exists before? (1 Reply)
Discussion started by: Zaxon
1 Replies

6. Infrastructure Monitoring

diffrence between method call and function call in perl

Hello, I have a problem with package and name space. require "/Mehran/DSGateEngineLib/general.pl"; use strict; sub System_Status_Main_Service_Status_Intrusion_Prevention { my %idpstatus; my @result; &General_ReadHash("/var/dsg/idp/settings",\%idpstatus); #print... (4 Replies)
Discussion started by: Zaxon
4 Replies

7. Shell Programming and Scripting

Function call

Hi foiks i am unable to find what is wrong in my code mu functionality is to exit from shell when i give 99 but it is not calling function ext Could you please correct me. read option if ; then ext else echo "out" fi function ext { echo "tested 99 and exit... (12 Replies)
Discussion started by: kojo
12 Replies

8. Shell Programming and Scripting

After exit from function it should not call other function

Below is my script that is function properly per my conditions but I am facing one problem here that is when one function fails then Iy should not check other functions but it calls the other function too So anyone can help me how could i achieve this? iNOUT i AM GIVING TO THE... (1 Reply)
Discussion started by: rohit22hamirpur
1 Replies

9. Shell Programming and Scripting

How to dynamically name as function in shell?

Hi all, Does anyone know if it possible to append a parameter to a function name? Something like the following: function tnsrec_${SERVICE_NAME} { code.. } Any ideas? (6 Replies)
Discussion started by: jonnyd
6 Replies

10. Homework & Coursework Questions

How to Dynamically Pass Parameter to plsql Function & Capture its Output Value in a Shell Variable?

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: 2. Relevant commands, code, scripts, algorithms: #! /bin/ksh v="ORG_ID" ... (2 Replies)
Discussion started by: sujitdas2104
2 Replies
ATEXIT(3)						   BSD Library Functions Manual 						 ATEXIT(3)

NAME
atexit -- register a function to be called on exit SYNOPSIS
#include <stdlib.h> int atexit(void (*function)(void)); int atexit_b(void (^function)(void)); DESCRIPTION
The atexit() function registers the given function to be called at program exit, whether via exit(3) or via return from the program's main(). Functions so registered are called in reverse order; no arguments are passed. If the provided function is located in a library that has been dynamically loaded (e.g. by dlopen()), it will be called when the library is unloaded (due to a call to dlclose()) or at program exit. The atexit_b() function is like atexit() except the callback is a block pointer instead of a function pointer. Note: The Block_copy() function (defined in <Blocks.h>) is used by atexit_b() to make a copy of the block, especially for the case when a stack-based block might go out of scope when the subroutine returns. These functions must not call exit(); if it should be necessary to terminate the process while in such a function, the _exit(2) function should be used. (Alternatively, the function may cause abnormal process termination, for example by calling abort(3).) At least 32 functions can always be registered, and more are allowed as long as sufficient memory can be allocated. RETURN VALUES
The atexit() and atexit_b() functions return the value 0 if successful; otherwise the value -1 is returned and the global variable errno is set to indicate the error. ERRORS
[ENOMEM] No memory was available to add the function to the list. The existing list of functions is unmodified. SEE ALSO
exit(3) STANDARDS
The atexit() function conforms to ISO/IEC 9899:1990 (``ISO C90''). BSD
September 6, 2002 BSD
All times are GMT -4. The time now is 08:05 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy