compiler/clib: Don't hide access to aroscbase behind a #define.
[AROS.git] / compiler / clib / sharecontextwithchild.c
blob0b9134897fa8ffc8c1cc5443134cd2d7c42b5fe7
1 /*
2 Copyright © 2009-2012, The AROS Development Team. All rights reserved.
3 $Id$
5 AROS function sharecontextwithchild().
6 */
8 #include "__arosc_privdata.h"
9 #include <aros/debug.h>
11 /*****************************************************************************
13 NAME */
14 #include <unistd.h>
16 void sharecontextwithchild (
18 /* SYNOPSIS */
19 int share)
21 /* FUNCTION
22 Controls sharing parent arosc context with child processes.
23 Must be called by parent process.
25 INPUTS
26 share - TRUE/FALSE - should parent share context with children
28 RESULT
30 NOTES
31 By calling this function the user of arosc.library controls how
32 new child processes use parent's arosc.library context.
34 When sharing is enabled, a child process will never create its
35 own arosc.library context and will alway use parent's context.
37 If you have a parent and child process allocating/dealocating
38 (malloc/free) memory for the same pointer, you must use this
39 function so that the memory will always be allocated in the
40 same arosc.libray context. Failure to do so will result with
41 GURU during free.
43 Things to be aware off:
44 - this function is dangeruos - you as a programmer must take care
45 of thread synchronization
46 - a child process cannot have life span longer than a parent process
47 - a child process may not call vfork or exec* functions - if such
48 feature is required, the vfork and exec* functions need to be
49 modified to work with flag set by this function
50 - once enabled, the sharing can be disabled at any time - when
51 the sharing is disabled, all child processes will acquire their
52 own arosc contexts when such need arises.
54 EXAMPLE
56 BUGS
58 SEE ALSO
60 INTERNALS
62 ******************************************************************************/
64 struct aroscbase *aroscbase = __GM_GetBase();
66 if (aroscbase)
68 if (share)
69 aroscbase->acb_flags |= SHARE_ACPD_WITH_CHILD;
70 else
71 aroscbase->acb_flags &= ~SHARE_ACPD_WITH_CHILD;
73 } /* sharecontextwithchild() */