os-hooks.c 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. /******************************************************************************
  2. *
  3. * File: $PXK/OS-HOOKS.C
  4. * Description: OS specific startup and cleanup hooks.
  5. * Author: RAM, HP/FSD
  6. * Created: 9-Mar-84
  7. * Modified: 15-Jul-85 10:10:51 (RAM)
  8. * Mode: Text
  9. * Package:
  10. * Status: Open Source: BSD License
  11. *
  12. * (c) Copyright 1983, Hewlett-Packard Company, see the file
  13. * HP_disclaimer at the root of the PSL file tree
  14. *
  15. * Redistribution and use in source and binary forms, with or without
  16. * modification, are permitted provided that the following conditions are met:
  17. *
  18. * * Redistributions of source code must retain the relevant copyright
  19. * notice, this list of conditions and the following disclaimer.
  20. * * Redistributions in binary form must reproduce the above copyright
  21. * notice, this list of conditions and the following disclaimer in the
  22. * documentation and/or other materials provided with the distribution.
  23. *
  24. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  25. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
  26. * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  27. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNERS OR
  28. * CONTRIBUTORS
  29. * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  30. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  31. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  32. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  33. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  34. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  35. * POSSIBILITY OF SUCH DAMAGE.
  36. *
  37. ******************************************************************************
  38. */
  39. /*
  40. * There used to be a collection of comments here describing revisions
  41. * made from about 1982 to 1989. I think those are by now of interest
  42. * to archaeologists! So anybody who wants to see them can consult older
  43. * copies of this file in the repositories. It is neverthless proper to
  44. * record the names of those who (in addition to the original author)
  45. * have contributed:
  46. * Chris Burdorf, Tsuyoshi Yamamoto, Leight Stoller
  47. */
  48. #include <stdio.h>
  49. #include <stdlib.h>
  50. #include <string.h>
  51. #include <setjmp.h>
  52. #include "psl.h"
  53. #if defined __linux__ || defined __CYGWIN__
  54. #define _(x) _ ## x
  55. #else
  56. #define _(x) x
  57. #endif
  58. jmp_buf mainenv;
  59. char *abs_execfilepath;
  60. void clear_iob(), clear_dtabsize();
  61. void _(psl_main)(int argc, char *argv[]);
  62. char **_(copy_argv)();
  63. int Debug = 0;
  64. int main(int argc, char *argv[])
  65. { TR1("main");
  66. int val;
  67. clear_iob(); /* clear garbage pointer in _iob[] */
  68. clear_dtabsize();
  69. /* fpsetround(FP_RZ); */
  70. /* init_malloc_param(); */ /* reset malloc parameters. */
  71. setvbuf(stdout,NULL,_IOLBF,BUFSIZ);
  72. /* Record path to exec file */
  73. if (argc > 0)
  74. abs_execfilepath = realpath(argv[0],NULL);
  75. if (getenv("BPSL_DEBUG") != NULL)
  76. Debug = 1;
  77. val=setjmp(mainenv); /* set non-local return point for exit */
  78. if (val == 0)
  79. _(psl_main)(argc,_(copy_argv)(argc, argv));
  80. exit(0);
  81. }
  82. int setupbpsandheap(int argc, char *argv[]);
  83. void _(os_startup_hook)(int argc, char *argv[])
  84. { TR1("os_startup_hook");
  85. setupbpsandheap(argc, argv); /* Allocate bps and heap areas. */
  86. }
  87. void _(os_cleanup_hook)()
  88. { TR1("os_cleanup_hook");
  89. longjmp(mainenv,1);
  90. }
  91. char *_(get_execfilepath)()
  92. { TR1("get_execfilepath");
  93. return abs_execfilepath;
  94. }
  95. void clear_iob()
  96. { TR1("clear_iob");
  97. }
  98. /*
  99. * Some static area must be initialized on hot start.
  100. * There may be other area to be initialized but we have no idea
  101. * to know them.
  102. *
  103. * _dtabsize ----_end
  104. */
  105. extern char *end;
  106. /*
  107. * Size of dtabsize is 0x34c bytes.
  108. */
  109. void clear_dtabsize()
  110. { TR1("clear_dtabsize");
  111. }
  112. /* end of os-hooks.c */