Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

178 lines
4.0 KiB

  1. # This File keeps the contents of miniperlmain.c.
  2. #
  3. # It was generated automatically by minimod.PL from the contents
  4. # of miniperlmain.c. Don't edit this file!
  5. #
  6. # ANY CHANGES MADE HERE WILL BE LOST!
  7. #
  8. package ExtUtils::Miniperl;
  9. require Exporter;
  10. @ISA = qw(Exporter);
  11. @EXPORT = qw(&writemain);
  12. $head= <<'EOF!HEAD';
  13. /*
  14. * "The Road goes ever on and on, down from the door where it began."
  15. */
  16. #ifdef OEMVS
  17. #pragma runopts(HEAP(1M,32K,ANYWHERE,KEEP,8K,4K))
  18. #endif
  19. #include "EXTERN.h"
  20. #define PERL_IN_MINIPERLMAIN_C
  21. #include "perl.h"
  22. static void xs_init (pTHX);
  23. static PerlInterpreter *my_perl;
  24. #if defined (__MINT__) || defined (atarist)
  25. /* The Atari operating system doesn't have a dynamic stack. The
  26. stack size is determined from this value. */
  27. long _stksize = 64 * 1024;
  28. #endif
  29. int
  30. main(int argc, char **argv, char **env)
  31. {
  32. int exitstatus;
  33. #ifdef PERL_GLOBAL_STRUCT
  34. #define PERLVAR(var,type) /**/
  35. #define PERLVARA(var,type) /**/
  36. #define PERLVARI(var,type,init) PL_Vars.var = init;
  37. #define PERLVARIC(var,type,init) PL_Vars.var = init;
  38. #include "perlvars.h"
  39. #undef PERLVAR
  40. #undef PERLVARA
  41. #undef PERLVARI
  42. #undef PERLVARIC
  43. #endif
  44. PERL_SYS_INIT3(&argc,&argv,&env);
  45. if (!PL_do_undump) {
  46. my_perl = perl_alloc();
  47. if (!my_perl)
  48. exit(1);
  49. perl_construct(my_perl);
  50. PL_perl_destruct_level = 0;
  51. }
  52. exitstatus = perl_parse(my_perl, xs_init, argc, argv, (char **)NULL);
  53. if (!exitstatus) {
  54. exitstatus = perl_run(my_perl);
  55. }
  56. perl_destruct(my_perl);
  57. perl_free(my_perl);
  58. PERL_SYS_TERM();
  59. exit(exitstatus);
  60. return exitstatus;
  61. }
  62. /* Register any extra external extensions */
  63. EOF!HEAD
  64. $tail=<<'EOF!TAIL';
  65. static void
  66. xs_init(pTHX)
  67. {
  68. }
  69. EOF!TAIL
  70. sub writemain{
  71. my(@exts) = @_;
  72. my($pname);
  73. my($dl) = canon('/','DynaLoader');
  74. print $head;
  75. foreach $_ (@exts){
  76. my($pname) = canon('/', $_);
  77. my($mname, $cname);
  78. ($mname = $pname) =~ s!/!::!g;
  79. ($cname = $pname) =~ s!/!__!g;
  80. print "EXTERN_C void boot_${cname} (pTHX_ CV* cv);\n";
  81. }
  82. my ($tail1,$tail2) = ( $tail =~ /\A(.*\n)(\s*\}.*)\Z/s );
  83. print $tail1;
  84. print "\tchar *file = __FILE__;\n";
  85. print "\tdXSUB_SYS;\n" if $] > 5.002;
  86. foreach $_ (@exts){
  87. my($pname) = canon('/', $_);
  88. my($mname, $cname, $ccode);
  89. ($mname = $pname) =~ s!/!::!g;
  90. ($cname = $pname) =~ s!/!__!g;
  91. print "\t{\n";
  92. if ($pname eq $dl){
  93. # Must NOT install 'DynaLoader::boot_DynaLoader' as 'bootstrap'!
  94. # boot_DynaLoader is called directly in DynaLoader.pm
  95. $ccode = "\t/* DynaLoader is a special case */\n
  96. \tnewXS(\"${mname}::boot_${cname}\", boot_${cname}, file);\n";
  97. print $ccode unless $SEEN{$ccode}++;
  98. } else {
  99. $ccode = "\tnewXS(\"${mname}::bootstrap\", boot_${cname}, file);\n";
  100. print $ccode unless $SEEN{$ccode}++;
  101. }
  102. print "\t}\n";
  103. }
  104. print $tail2;
  105. }
  106. sub canon{
  107. my($as, @ext) = @_;
  108. foreach(@ext){
  109. # might be X::Y or lib/auto/X/Y/Y.a
  110. next if s!::!/!g;
  111. s:^(lib|ext)/(auto/)?::;
  112. s:/\w+\.\w+$::;
  113. }
  114. grep(s:/:$as:, @ext) if ($as ne '/');
  115. @ext;
  116. }
  117. 1;
  118. __END__
  119. =head1 NAME
  120. ExtUtils::Miniperl, writemain - write the C code for perlmain.c
  121. =head1 SYNOPSIS
  122. C<use ExtUtils::Miniperl;>
  123. C<writemain(@directories);>
  124. =head1 DESCRIPTION
  125. This whole module is written when perl itself is built from a script
  126. called minimod.PL. In case you want to patch it, please patch
  127. minimod.PL in the perl distribution instead.
  128. writemain() takes an argument list of directories containing archive
  129. libraries that relate to perl modules and should be linked into a new
  130. perl binary. It writes to STDOUT a corresponding perlmain.c file that
  131. is a plain C file containing all the bootstrap code to make the
  132. modules associated with the libraries available from within perl.
  133. The typical usage is from within a Makefile generated by
  134. ExtUtils::MakeMaker. So under normal circumstances you won't have to
  135. deal with this module directly.
  136. =head1 SEE ALSO
  137. L<ExtUtils::MakeMaker>
  138. =cut