home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / ixemul-45.0-src.tgz / tar.out / contrib / ixemul / static / vfork_setup_child.c < prev   
C/C++ Source or Header  |  1996-10-04  |  935b  |  38 lines

  1. extern void ix_get_variables(int);  /* from crt0.c! */
  2. extern void ix_resident();
  3. extern int __datadata_relocs();
  4. void __init_stk_limit(void **limit, unsigned long argbytes);
  5. extern void *__stk_limit;
  6. extern unsigned long __stk_argbytes;
  7.  
  8. static inline unsigned int get_a4(void)
  9. {
  10.   unsigned int res;
  11.  
  12.   asm ("movel a4,%0" : "=g" (res));
  13.   return res;
  14. }
  15.  
  16. static inline int dbsize(void)
  17. {
  18.   int res;
  19.  
  20.   asm ("movel #___data_size,%0; addl #___bss_size,%0" : "=r" (res));
  21.   return res;
  22. }
  23.  
  24. void vfork_setup_child(void)
  25. {
  26.   /* this re-relocates the data segment */
  27.   ix_resident(4, get_a4(), dbsize(), __datadata_relocs);
  28.  
  29.   /* pass the new addresses for internal variables (e.g. errno) to
  30.      ixemul. Pass '1' to tell ix_get_variables that it is called from
  31.      here */
  32.   ix_get_variables(1);
  33.  
  34.   /* Set the limit variable to finish the initialization of the stackextend
  35.      code.  */
  36.   __init_stk_limit(&__stk_limit, __stk_argbytes);
  37. }
  38.