39 #ifndef DOXYGEN_INPROGRESS
48 #define PIP_OPTS_NONE (0x0)
50 #define PIP_MODE_PTHREAD (0x1000U)
51 #define PIP_MODE_PROCESS (0x2000U)
53 #define PIP_MODE_PROCESS_PRELOAD (0x2100U)
54 #define PIP_MODE_PROCESS_PIPCLONE (0x2200U)
55 #define PIP_MODE_PROCESS_GOT (0x2400U)
56 #define PIP_MODE_MASK (0xFF00U)
58 #define PIP_ENV_MODE "PIP_MODE"
59 #define PIP_ENV_MODE_THREAD "thread"
60 #define PIP_ENV_MODE_PTHREAD "pthread"
61 #define PIP_ENV_MODE_PROCESS "process"
62 #define PIP_ENV_MODE_PROCESS_PRELOAD "process:preload"
63 #define PIP_ENV_MODE_PROCESS_PIPCLONE "process:pipclone"
64 #define PIP_ENV_MODE_PROCESS_GOT "process:got"
66 #define PIP_ENV_STOP_ON_START "PIP_STOP_ON_START"
68 #define PIP_ENV_GDB_PATH "PIP_GDB_PATH"
69 #define PIP_ENV_GDB_COMMAND "PIP_GDB_COMMAND"
70 #define PIP_ENV_GDB_SIGNALS "PIP_GDB_SIGNALS"
71 #define PIP_ENV_SHOW_MAPS "PIP_SHOW_MAPS"
72 #define PIP_ENV_SHOW_PIPS "PIP_SHOW_PIPS"
74 #define PIP_VALID_OPTS \
75 ( PIP_MODE_PTHREAD | PIP_MODE_PROCESS_PRELOAD | \
76 PIP_MODE_PROCESS_PIPCLONE | PIP_MODE_PROCESS_GOT )
78 #define PIP_ENV_STACKSZ "PIP_STACKSZ"
80 #define PIP_MAGIC_NUM (-747)
82 #define PIP_PIPID_ROOT (PIP_MAGIC_NUM-1)
83 #define PIP_PIPID_MYSELF (PIP_MAGIC_NUM-2)
84 #define PIP_PIPID_ANY (PIP_MAGIC_NUM-3)
85 #define PIP_PIPID_NULL (PIP_MAGIC_NUM-4)
86 #define PIP_PIPID_SELF PIP_PIPID_MYSELF
88 #define PIP_NTASKS_MAX (300)
90 #define PIP_CPUCORE_FLAG_SHIFT (24)
91 #define PIP_CPUCORE_FLAG_MASK (0xFFU<<PIP_CPUCORE_FLAG_SHIFT)
92 #define PIP_CPUCORE_CORENO_MAX ((1U<<20)-1)
93 #define PIP_CPUCORE_ASIS (0x1U<<PIP_CPUCORE_FLAG_SHIFT)
94 #define PIP_CPUCORE_ABS (0x2U<<PIP_CPUCORE_FLAG_SHIFT)
95 #define PIP_CPUCORE_CORENO_MASK ((0x1U<<PIP_CPUCORE_FLAG_SHIFT)-1)
97 #define PIP_YIELD_DEFAULT (0x0U)
98 #define PIP_YIELD_USER (0x1U)
99 #define PIP_YIELD_SYSTEM (0x2U)
110 } pip_spawn_program_t;
112 typedef int (*pip_spawnhook_t)(
void* );
115 pip_spawnhook_t before;
116 pip_spawnhook_t after;
121 typedef uintptr_t pip_id_t;
128 #define INLINE inline static
252 int pip_init(
int *pipidp,
int *ntasks,
void **root_expp, uint32_t opts );
319 #ifndef DOXYGEN_INPROGRESS
323 char *prog,
char **argv,
char **envv,
324 void *exp,
void *aux ) {
325 memset( progp, 0,
sizeof(pip_spawn_program_t) );
329 progp->prog = argv[0];
333 extern char **environ;
334 progp->envv = environ;
381 #ifndef DOXYGEN_INPROGRESS
385 char *prog,
char *funcname,
void *arg,
char **envv,
386 void *exp,
void *aux ) {
387 memset( progp, 0,
sizeof(pip_spawn_program_t) );
389 progp->funcname = funcname;
392 extern char **environ;
393 progp->envv = environ;
455 #ifndef DOXYGEN_INPROGRESS
459 pip_spawnhook_t before,
460 pip_spawnhook_t after,
462 hook->before = before;
464 hook->hookarg = hookarg;
537 pip_spawn_hook_t *hookp );
611 int pip_spawn(
char *filename,
char **argv,
char **envv,
612 uint32_t coreno,
int *pipidp,
613 pip_spawnhook_t before, pip_spawnhook_t after,
void *hookarg);
660 __attribute__ ((format (printf, 2, 3)));
704 __attribute__ ((format (printf, 3, 4)));
743 __attribute__ ((format (printf, 3, 4)));
903 int pip_wait(
int pipid,
int *status );
1258 #ifndef DOXYGEN_INPROGRESS
1260 pid_t pip_gettid(
void );
1261 void pip_glibc_lock(
void );
1262 void pip_glibc_unlock(
void );
1263 void pip_debug_info(
void );
1264 size_t pip_idstr(
char*,
size_t );
1265 int pip_check_pie(
const char*,
int );
1271 #include <pip/pip_blt.h>
1272 #include <pip/pip_dlfcn.h>
1273 #include <pip/pip_signal.h>
void pip_spawn_from_main(pip_spawn_program_t *progp, char *prog, char **argv, char **envv, void *exp, void *aux)
Setting information to invoke a PiP task starting from the main function.
Definition: pip.h:322
int pip_init(int *pipidp, int *ntasks, void **root_expp, uint32_t opts)
Initialize the PiP library.
int pip_get_dlmopen_info(int pipid, void **handlep, long *lmidp)
Retrieve the loaded link map info. of the specified Pip task.
void pip_spawn_from_func(pip_spawn_program_t *progp, char *prog, char *funcname, void *arg, char **envv, void *exp, void *aux)
Setting information to invoke a PiP task starting from a function defined in a program.
Definition: pip.h:384
int pip_fin(void)
Finalize the PiP library.
void pip_exit(int status)
terminate the calling PiP task
int pip_is_initialized(void)
Query is PiP library is already initialized.
int pip_named_export(void *exp, const char *format,...) __attribute__((format(printf
export an address of the calling PiP root or a PiP task to the others.
int pip_isa_task(void)
check if calling PiP task is a PiP task or not
int int int pip_named_tryimport(int pipid, void **expp, const char *format,...) __attribute__((format(printf
import the named exported address (non-blocking)
int pip_wait_any(int *pipid, int *status)
Wait for the termination of any PiP task.
int pip_get_system_id(int pipid, pip_id_t *idp)
deliver a process or thread ID defined by the system
int int int int pip_export(void *exp)
export an address
int pip_trywait(int pipid, int *status)
wait for the termination of a PiP task in a non-blocking way
int pip_isa_root(void)
check if calling PiP task is a PiP root or not
int pip_get_aux(void **auxp)
Retrieve the user data associated with a PiP task.
int pip_import(int pipid, void **expp)
import exported address of a PiP task
int pip_set_aux(void *aux)
Associate user data with a PiP task.
int pip_is_threaded(int *flagp)
check if PiP execution mode is pthread or not
int pip_trywait_any(int *pipid, int *status)
non-blocking version of pip_wait_any
int pip_wait(int pipid, int *status)
wait for the termination of a PiP task
int pip_is_shared_fd(int *flagp)
check if file descriptors are shared or not. This is equivalent with the pip_is_threaded function...
int pip_task_spawn(pip_spawn_program_t *progp, uint32_t coreno, uint32_t opts, int *pipidp, pip_spawn_hook_t *hookp)
Spawning a PiP task.
const char * pip_get_mode_str(void)
get a character string of the current execution mode
int pip_get_ntasks(int *ntasksp)
get the maximum number of the PiP tasks
void pip_abort(void)
Kill all PiP tasks and then kill PiP root.
int pip_spawn(char *filename, char **argv, char **envv, uint32_t coreno, int *pipidp, pip_spawnhook_t before, pip_spawnhook_t after, void *hookarg)
spawn a PiP task (PiP v1 API and deprecated)
int pip_get_mode(int *modep)
get the PiP execution mode
int int pip_named_import(int pipid, void **expp, const char *format,...) __attribute__((format(printf
import the named exported address
int pip_kill_all_tasks(void)
kill all PiP tasks
void pip_spawn_hook(pip_spawn_hook_t *hook, pip_spawnhook_t before, pip_spawnhook_t after, void *hookarg)
Setting invocation hook information.
Definition: pip.h:458
int pip_get_pipid(int *pipidp)
get PiP ID of the calling task