2
0

generate_vax_transfer.com 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. $! File: generate_vax_transfer.com
  2. $!
  3. $! $Id$
  4. $!
  5. $! File to generate and compile the VAX transfer vectors from reading in the
  6. $! Alpha/Itanium gnv_libcurl_symbols.opt file.
  7. $!
  8. $! This procedure patches the VAX Macro32 assembler to be case sensitive
  9. $! and then compiles the generated
  10. $!
  11. $! The output of this procedure is:
  12. $! gnv_libcurl_xfer.mar_exact
  13. $! gnv_libcurl_xfer.obj
  14. $! gnv_libcurl_xfer.opt
  15. $! macro32_exactcase.exe
  16. $!
  17. $! Copyright 2013 - 2022, John Malmberg
  18. $!
  19. $! Permission to use, copy, modify, and/or distribute this software for any
  20. $! purpose with or without fee is hereby granted, provided that the above
  21. $! copyright notice and this permission notice appear in all copies.
  22. $!
  23. $! THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  24. $! WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  25. $! MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  26. $! ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  27. $! WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  28. $! ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
  29. $! OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  30. $!
  31. $! SPDX-License-Identifier: ISC
  32. $!
  33. $! 20-Jul-2013 J. Malmberg
  34. $!============================================================================
  35. $!
  36. $! Save this so we can get back.
  37. $ default_dir = f$environment("default")
  38. $!
  39. $ on warning then goto all_exit
  40. $!
  41. $! Want hard tabs in the generated file.
  42. $ tab[0,8] = 9
  43. $!
  44. $! This procedure is used on VAX only
  45. $ if (f$getsyi("HW_MODEL") .ge. 1024)
  46. $ then
  47. $ write sys$output "This procedure is only used on VAX."
  48. $ goto all_exit
  49. $ endif
  50. $!
  51. $!
  52. $! Get the libcurl version to generate the ident string.
  53. $! ident string is max of 31 characters.
  54. $!
  55. $ ident_string = "unknown"
  56. $ open/read cver [-.-.include.curl]curlver.h
  57. $cver_loop:
  58. $ read/end=cver_loop_end cver line_in
  59. $ line_in = f$edit(line_in, "COMPRESS,TRIM")
  60. $ if line_in .eqs. "" then goto cver_loop
  61. $ code = f$extract(0, 1, line_in)
  62. $ if code .nes. "#" then goto cver_loop
  63. $ directive = f$element(0, " ", line_in)
  64. $ if directive .nes. "#define" then goto cver_loop
  65. $ name = f$element(1, " ", line_in)
  66. $ if name .nes. "LIBCURL_VERSION" then goto cver_loop
  67. $ ident_string = f$element(2, " ", line_in) - "" - ""
  68. $cver_loop_end:
  69. $ close cver
  70. $!
  71. $ open/read aopt gnv_libcurl_symbols.opt
  72. $!
  73. $! Write out the header
  74. $ gosub do_header
  75. $!
  76. $ open/append vopt gnv_libcurl_xfer.mar_exact
  77. $ write vopt tab,".IDENT /", ident_string, "/"
  78. $!
  79. $ write vopt tab, ".PSECT LIBCURL_XFERVECTORS -"
  80. $ write vopt tab,tab,tab, "PIC,USR,CON,REL,GBL,SHR,EXE,RD,NOWRT,QUAD"
  81. $ write vopt ""
  82. $ write vopt tab, "SPARE", tab, "; never delete this spare"
  83. $ write vopt ";"
  84. $ write vopt ";", tab, "Exact case and upper case transfer vectors"
  85. $!
  86. $ alias_count = 0
  87. $vector_loop:
  88. $!
  89. $! Read in symbol_vector
  90. $!
  91. $ read/end=vector_loop_end aopt line_in
  92. $ line = f$edit(line_in, "UNCOMMENT,COMPRESS,TRIM")
  93. $ if line .eqs. "" then goto vector_loop
  94. $!
  95. $ line_u = f$edit(line, "UPCASE")
  96. $ key = f$element(0, "=", line_u)
  97. $ if (key .eqs. "SYMBOL_VECTOR")
  98. $ then
  99. $ symbol_string = f$element(1, "=", line) - "("
  100. $ symbol_type = f$element(2, "=", line_u) - ")"
  101. $ symbol_name = f$element(1, "/", symbol_string)
  102. $ if symbol_type .nes. "PROCEDURE"
  103. $ then
  104. $ write sys$output "%CURLBUILD-W-NOTPROC, " + -
  105. $ "This procedure can only handle procedure vectors"
  106. $ write sys$output -
  107. "Data vectors require manual construction for which this procedure or"
  108. $ write sys$output -
  109. "the shared library needs to be updated to resolve."
  110. $ write sys$output -
  111. "the preferred solution is to have a procedure return the address of the "
  112. $ write sys$output -
  113. "the variable instead of having a variable, as if the size of the variable "
  114. write sys$output -
  115. "changes, the symbol vector is no longer backwards compatible."
  116. $ endif
  117. $ if (symbol_name .eqs. "/")
  118. $ then
  119. $ symbol_name = symbol_string
  120. $ write vopt tab, symbol_type, tab, symbol_name
  121. $ else
  122. $ alias_count = alias_count + 1
  123. $ symbol_alias = f$element(0, "/", symbol_string)
  124. $ write vopt -
  125. tab, "''symbol_type_U", tab, symbol_name, tab, symbol_alias
  126. $ endif
  127. $ endif
  128. $ goto vector_loop
  129. $vector_loop_end:
  130. $!
  131. $! End of pass one, second pass needed if aliases exist
  132. $ close aopt
  133. $!
  134. $ if alias_count .eq. 0 then goto finish_file
  135. $!
  136. $! Start pass 2, write stub routine header
  137. $!
  138. $ open/read aopt gnv_libcurl_symbols.opt
  139. $!
  140. $alias_loop:
  141. $!
  142. $! Read in symbol_vector
  143. $!
  144. $ read/end=alias_loop_end aopt line_in
  145. $ line = f$edit(line_in, "UNCOMMENT,COMPRESS,TRIM")
  146. $ if line .eqs. "" then goto alias_loop
  147. $!
  148. $ line_u = f$edit(line, "UPCASE")
  149. $ key = f$element(0, "=", line_u)
  150. $ if (key .eqs. "SYMBOL_VECTOR")
  151. $ then
  152. $ symbol_string = f$element(1, "=", line) - "("
  153. $ symbol_type = f$element(2, "=", line_u) - ")"
  154. $ symbol_name = f$element(1, "/", symbol_string)
  155. $ if (symbol_name .eqs. "/")
  156. $ then
  157. $ symbol_name = symbol_string
  158. $ else
  159. $ alias_count = alias_count + 1
  160. $ symbol_alias = f$element(0, "/", symbol_string)
  161. $ write vopt tab, ".ENTRY", tab, symbol_alias, ", ^M<>"
  162. $ endif
  163. $ endif
  164. $ goto alias_loop
  165. $! read in symbol_vector
  166. $! if not alias, then loop
  167. $! write out subroutine name
  168. $!
  169. $alias_loop_end:
  170. $!
  171. $ write vopt tab, "MOVL #1, R0"
  172. $ write vopt tab, "RET"
  173. $!
  174. $finish_file:
  175. $!
  176. $ write vopt ""
  177. $ write vopt tab, ".END"
  178. $!
  179. $ close aopt
  180. $ close vopt
  181. $!
  182. $! Patch the Macro32 compiler
  183. $!----------------------------
  184. $ patched_macro = "sys$disk:[]macro32_exactcase.exe"
  185. $ if f$search(patched_macro) .eqs. ""
  186. $ then
  187. $ copy sys$system:macro32.exe 'patched_macro'
  188. $ patch @macro32_exactcase.patch
  189. $ endif
  190. $ define/user macro32 'patched_macro'
  191. $ macro/object=gnv_libcurl_xfer.obj gnv_libcurl_xfer.mar_exact
  192. $!
  193. $! Create the option file for linking the shared image.
  194. $ create gnv_libcurl_xfer.opt
  195. $ open/append lco gnv_libcurl_xfer.opt
  196. $ write lco "gsmatch=lequal,1,1"
  197. $ write lco "cluster=transfer_vector,,,''default_dir'gnv_libcurl_xfer"
  198. $ write lco "collect=libcurl_global, libcurl_xfervectors"
  199. $ close lco
  200. $!
  201. $!
  202. $ goto all_exit
  203. $!
  204. $! Process the header
  205. $do_header:
  206. $!
  207. $! Force the mode of the file to same as text editor generated.
  208. $ create gnv_libcurl_xfer.mar_exact
  209. $deck
  210. ; File: gnv_libcurl_xfer.mar_exact
  211. ;
  212. ; VAX transfer vectors
  213. ;
  214. ; This needs to be compiled with a specialized patch on Macro32 to make it
  215. ; preserve the case of symbols instead of converting it to uppercase.
  216. ;
  217. ; This patched Macro32 requires all directives to be in upper case.
  218. ;
  219. ; There are three sets of symbols for transfer vectors here.
  220. ;
  221. ; The first for upper case which matches the tradition method of generating
  222. ; VAX transfer vectors.
  223. ;
  224. ; The second is the exact case for compatibility with open source C programs
  225. ; that expect exact case symbols in images. These are separated because a
  226. ; previous kit had only upper case symbols.
  227. ;
  228. ; The third is the routine stub that is used to resolve part of the upper
  229. ; case transfer vectors, with exact case entry symbols.
  230. ;
  231. ; When you add routines, you need to add them after the second set of transfer
  232. ; vectors for both upper and exact case, and then additional entry points
  233. ; in upper case added to stub routines.
  234. ;
  235. ;*************************************************************************
  236. .TITLE libcurl_xfer - Transfer vector for libcurl
  237. .DISABLE GLOBAL
  238. ;
  239. ; Macro to generate a transfer vector entry
  240. ;
  241. .MACRO PROCEDURE NAME
  242. .EXTRN 'NAME
  243. .ALIGN QUAD
  244. .TRANSFER 'NAME
  245. .MASK 'NAME
  246. JMP 'NAME+2
  247. .ENDM
  248. .MACRO PROCEDUREU NAME NAMEU
  249. .EXTRN 'NAME
  250. .ALIGN QUAD
  251. .TRANSFER 'NAMEU
  252. .MASK 'NAME
  253. JMP 'NAME+2
  254. .ENDM
  255. ;
  256. ;
  257. ; Macro to reserve a spare entry.
  258. ;
  259. .MACRO SPARE
  260. .ALIGN QUAD
  261. .ALIGN QUAD
  262. .QUAD 0
  263. .ENDM
  264. $EOD
  265. $!
  266. $!
  267. $ return
  268. $!
  269. $all_exit:
  270. $set def 'default_dir'
  271. $exit '$status'