Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Initial open-source release

  • Loading branch information...
commit fccc6851ccd2cb4fd9e83ba7b8c8d6d780ed3e13 0 parents
MLstate authored
Showing with 30,400 additions and 0 deletions.
  1. +18 −0 .gitignore
  2. +3 −0  CHANGELOG
  3. +661 −0 LICENSE
  4. +219 −0 Makefile
  5. +103 −0 README
  6. +42 −0 _tags
  7. +12 −0 appruntime.mllib
  8. +17 −0 appruntime/_tags
  9. +226 −0 appruntime/connection.ml
  10. +213 −0 appruntime/epoll.ml
  11. +4 −0 appruntime/io/_tags
  12. +384 −0 appruntime/io/binding_epoll.c
  13. +461 −0 appruntime/io/binding_iocp.c
  14. +81 −0 appruntime/io/dns.c
  15. +50 −0 appruntime/iocp.ml
  16. +3 −0  appruntime/libio.clib
  17. +98 −0 appruntime/netAddr.ml
  18. +59 −0 appruntime/netAddr.mli
  19. +161 −0 appruntime/netStats.ml
  20. +30 −0 appruntime/netStats.mli
  21. +595 −0 appruntime/resourceTracker.ml
  22. +186 −0 appruntime/resourceTracker.mli
  23. +726 −0 appruntime/scheduler.ml
  24. +391 −0 appruntime/scheduler.mli
  25. +3 −0  appruntime/scheduler/_tags
  26. +203 −0 appruntime/scheduler/epoll.mli
  27. +108 −0 appruntime/scheduler/schedulerExc.ml
  28. +189 −0 appruntime/scheduler/schedulerJob.ml
  29. +674 −0 appruntime/scheduler/schedulerKer.ml
  30. +415 −0 appruntime/scheduler/schedulerKer.mli
  31. +98 −0 appruntime/scheduler/schedulerLog.ml
  32. +251 −0 appruntime/testSchedulerKer.ml
  33. +300 −0 appruntime/test_scheduler.ml
  34. +38 −0 appruntime/test_scheduler_write_timeout.ml
  35. +190 −0 build/Makefile.bld
  36. +88 −0 build/README
  37. +521 −0 build/bld.sh
  38. +133 −0 build/gen_myocamlbuild.sh
  39. +530 −0 build/myocamlbuild_prefix.ml
  40. +69 −0 build/myocamlbuild_suffix.ml
  41. +50 −0 build_libs
  42. +803 −0 build_rules.ml
  43. +92 −0 build_tools
  44. +1 −0  buildinfos.mllib
  45. +8 −0 buildinfos/buildInfos.ml.post
  46. +9 −0 buildinfos/buildInfos.ml.pre
  47. +102 −0 buildinfos/buildInfos.mli
  48. +142 −0 buildinfos/generate_buildinfos.sh
  49. +1 −0  buildinfos/version.txt
  50. +21 −0 compilerlib.mllib
  51. +15 −0 compilerlib/_tags
  52. +102 −0 compilerlib/annot.ml
  53. +202 −0 compilerlib/annot.mli
  54. +18 −0 compilerlib/annotMap.ml
  55. +22 −0 compilerlib/annotMap.mli
  56. +18 −0 compilerlib/annotSet.ml
  57. +22 −0 compilerlib/annotSet.mli
  58. +37 −0 compilerlib/bslKey.ml
  59. +82 −0 compilerlib/bslKey.mli
  60. +22 −0 compilerlib/bslKeyMap.ml
  61. +25 −0 compilerlib/bslKeyMap.mli
  62. +18 −0 compilerlib/bslKeySet.ml
  63. +18 −0 compilerlib/bslKeySet.mli
  64. +18 −0 compilerlib/bslKeyTable.ml
  65. +18 −0 compilerlib/bslKeyTable.mli
  66. +222 −0 compilerlib/graphUtils.ml
  67. +44 −0 compilerlib/hintUtils.ml
  68. +57 −0 compilerlib/hintUtils.mli
  69. +225 −0 compilerlib/ident.ml
  70. +112 −0 compilerlib/ident.mli
  71. +18 −0 compilerlib/identMap.ml
  72. +18 −0 compilerlib/identMap.mli
  73. +18 −0 compilerlib/identSet.ml
  74. +18 −0 compilerlib/identSet.mli
  75. +18 −0 compilerlib/identTable.ml
  76. +18 −0 compilerlib/identTable.mli
  77. +28 −0 compilerlib/installDir.ml
  78. +58 −0 compilerlib/installDir.mli
  79. +30 −0 compilerlib/langAst.ml
  80. +99 −0 compilerlib/langAst.mli
  81. +40 −0 compilerlib/langPrint.ml
  82. +94 −0 compilerlib/langPrint.mli
  83. +19 −0 compilerlib/langUtils.ml
  84. +23 −0 compilerlib/langUtils.mli
  85. +364 −0 compilerlib/oManager.ml
  86. +203 −0 compilerlib/oManager.mli
  87. +1,894 −0 compilerlib/objectFiles.ml
  88. +278 −0 compilerlib/objectFiles.mli
  89. +155 −0 compilerlib/opadep.sh
  90. +52 −0 compilerlib/opxviewer.ml
  91. +90 −0 compilerlib/template.ml
  92. +82 −0 compilerlib/template.mli
  93. +290 −0 compilerlib/warningClass.ml
  94. +257 −0 compilerlib/warningClass.mli
  95. +70 −0 config.mli
  96. +629 −0 configure
  97. +113 −0 copyright/01_ocaml
  98. +22 −0 copyright/02_cryptokit
  99. +22 −0 copyright/03_ocamlgraph
  100. +29 −0 copyright/04_jsmin
  101. +20 −0 copyright/05_jquery
  102. +22 −0 copyright/06_ulex
  103. +40 −0 copyright/07_xmlm
  104. +26 −0 copyright/08_libnatpmp
  105. +26 −0 copyright/09_miniupnpc
  106. +75 −0 copyright/copyright
  107. +72 −0 database.mllib
  108. +17 −0 database/_tags
  109. +340 −0 database/badop.ml
  110. +56 −0 database/badop/badop_lib.ml
  111. +64 −0 database/badop/badop_lib.mli
  112. +410 −0 database/badop/badop_structure.ml
  113. +98 −0 database/badop_check.ml
  114. +124 −0 database/badop_client.ml
  115. +21 −0 database/badop_client.mli
  116. +115 −0 database/badop_debug.ml
  117. +20 −0 database/badop_debug.mli
  118. +263 −0 database/badop_dispatcher.ml
  119. +21 −0 database/badop_dispatcher.mli
  120. +186 −0 database/badop_local.ml
  121. +39 −0 database/badop_local.mli
  122. +164 −0 database/badop_locator.ml
  123. +76 −0 database/badop_locator.mli
  124. +202 −0 database/badop_meta.ml
  125. +34 −0 database/badop_meta.mli
  126. +168 −0 database/badop_protocol.ml
  127. +147 −0 database/badop_server.ml
  128. +26 −0 database/badop_server.mli
  129. +115 −0 database/badop_stash.ml
  130. +20 −0 database/badop_stash.mli
  131. +79 −0 database/badop_stats.ml
  132. +20 −0 database/badop_stats.mli
  133. +19 −0 database/badop_sync.ml
  134. +34 −0 database/badop_sync.mli
  135. +19 −0 database/badop_trans.ml
  136. +37 −0 database/badop_trans.mli
  137. +143 −0 database/badop_workaround.ml
  138. +26 −0 database/badop_workaround.mli
  139. +59 −0 database/badop_wrapper_template.ml
  140. +20 −0 database/badop_wrapper_template.mli
  141. +56 −0 database/dataImpl.ml
  142. +28 −0 database/dataImpl.mli
  143. +81 −0 database/database_server.ml
  144. +254 −0 database/database_tool.ml
  145. +18 −0 database/db3/_tags
  146. +34 −0 database/db3/backup.ml
  147. +179 −0 database/db3/common.ml
  148. +47 −0 database/db3/datas.ml
  149. +29 −0 database/db3/datas.mli
  150. +97 −0 database/db3/dot.ml
  151. +18 −0 database/db3/dot.mli
  152. +19 −0 database/db3/eid.ml
  153. +29 −0 database/db3/eid.mli
  154. +18 −0 database/db3/eidMap.ml
  155. +18 −0 database/db3/eidMap.mli
  156. +733 −0 database/db3/hldb.ml
  157. +120 −0 database/db3/hldb.mli
  158. +6 −0 database/db3/io/_tags
  159. +19 −0 database/db3/io/dbIo.ml
  160. +93 −0 database/db3/io/dbIoSig.ml
  161. +184 −0 database/db3/io/dbTypes.ml
  162. +468 −0 database/db3/io/fileIo.ml
  163. +19 −0 database/db3/io/fileIo.mli
  164. +362 −0 database/db3/io/ioMmap.ml
  165. +18 −0 database/db3/io/ioMmap.mli
  166. +54 −0 database/db3/io/ioSig.ml
  167. +180 −0 database/db3/io/ioUnix.ml
  168. +18 −0 database/db3/io/ioUnix.mli
  169. +1,224 −0 database/db3/ioManager.ml
  170. +91 −0 database/db3/ioManager.mli
  171. +18 −0 database/db3/keyMap.ml
  172. +18 −0 database/db3/keyMap.mli
  173. +22 −0 database/db3/keyRecMap.ml
  174. +42 −0 database/db3/keyRecMap.mli
  175. +120 −0 database/db3/keys.ml
  176. +44 −0 database/db3/keys.mli
  177. +3 −0  database/db3/migration/_tags
  178. +173 −0 database/db3/migration/init.ml
  179. +114 −0 database/db3/migration/migration.ml
  180. +24 −0 database/db3/migration/migration.mli
  181. +278 −0 database/db3/migration/migration_18.ml
  182. +57 −0 database/db3/migration/migration_19.ml
  183. +47 −0 database/db3/migration/migration_20.ml
  184. +170 −0 database/db3/migration/migration_21.ml
  185. +76 −0 database/db3/migration/migration_22.ml
  186. +55 −0 database/db3/migration/migration_23.ml
  187. +238 −0 database/db3/migration/migration_24.ml
  188. +377 −0 database/db3/migration/migration_25.ml
  189. +28 −0 database/db3/migration/migration_26.ml
  190. +483 −0 database/db3/node.ml
  191. +94 −0 database/db3/node.mli
  192. +104 −0 database/db3/path.ml
  193. +67 −0 database/db3/path.mli
  194. +254 −0 database/db3/queryMap.ml
  195. +38 −0 database/db3/queryMap.mli
  196. +19 −0 database/db3/revision.ml
  197. +33 −0 database/db3/revision.mli
  198. +267 −0 database/db3/revisionMachine.ml
  199. +21 −0 database/db3/revisionMachine.mli
  200. +18 −0 database/db3/revisionMap.ml
  201. +18 −0 database/db3/revisionMap.mli
  202. +879 −0 database/db3/session.ml
  203. +57 −0 database/db3/session.mli
  204. +961 −0 database/db3/transaction.ml
  205. +64 −0 database/db3/transaction.mli
  206. +19 −0 database/db3/uid.ml
  207. +33 −0 database/db3/uid.mli
  208. +18 −0 database/db3/uidMap.ml
  209. +18 −0 database/db3/uidMap.mli
  210. +327 −0 database/db3/unwind.ml
  211. +141 −0 database/db3/unwind.mli
  212. +416 −0 database/dbgraph.ml
  213. +42 −0 database/gml_parser.trx
Sorry, we could not display the entire diff because too many files (1,857) changed.
18 .gitignore
@@ -0,0 +1,18 @@
+_build
+*~
+.*.swp
+.*.swo
+.DS_Store
+\#*#
+.#*
+TAGS
+._d
+config.ml
+config.sh
+config.make
+config.log
+doc.odocl
+access.log
+error.log
+*.native
+repos/
3  CHANGELOG
@@ -0,0 +1,3 @@
+opa (1.0s3.4) unstable; urgency=low
+ * initial open-source release
+ -- Louis Gesbert <louis.gesbert@mlstate.com> Fri, 10 Jun 2011 15:44:20 +0200
661 LICENSE
@@ -0,0 +1,661 @@
+ GNU AFFERO GENERAL PUBLIC LICENSE
+ Version 3, 19 November 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The GNU Affero General Public License is a free, copyleft license for
+software and other kinds of works, specifically designed to ensure
+cooperation with the community in the case of network server software.
+
+ The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works. By contrast,
+our General Public Licenses are intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+ Developers that use our General Public Licenses protect your rights
+with two steps: (1) assert copyright on the software, and (2) offer
+you this License which gives you legal permission to copy, distribute
+and/or modify the software.
+
+ A secondary benefit of defending all users' freedom is that
+improvements made in alternate versions of the program, if they
+receive widespread use, become available for other developers to
+incorporate. Many developers of free software are heartened and
+encouraged by the resulting cooperation. However, in the case of
+software used on network servers, this result may fail to come about.
+The GNU General Public License permits making a modified version and
+letting the public access it on a server without ever releasing its
+source code to the public.
+
+ The GNU Affero General Public License is designed specifically to
+ensure that, in such cases, the modified source code becomes available
+to the community. It requires the operator of a network server to
+provide the source code of the modified version running there to the
+users of that server. Therefore, public use of a modified version, on
+a publicly accessible server, gives the public access to the source
+code of the modified version.
+
+ An older license, called the Affero General Public License and
+published by Affero, was designed to accomplish similar goals. This is
+a different license, not a version of the Affero GPL, but Affero has
+released a new version of the Affero GPL which permits relicensing under
+this license.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ TERMS AND CONDITIONS
+
+ 0. Definitions.
+
+ "This License" refers to version 3 of the GNU Affero General Public License.
+
+ "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+ "The Program" refers to any copyrightable work licensed under this
+License. Each licensee is addressed as "you". "Licensees" and
+"recipients" may be individuals or organizations.
+
+ To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy. The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+ A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+ To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy. Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+ To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies. Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+ An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License. If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+ 1. Source Code.
+
+ The "source code" for a work means the preferred form of the work
+for making modifications to it. "Object code" means any non-source
+form of a work.
+
+ A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+ The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form. A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+ The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities. However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work. For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+ The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+ The Corresponding Source for a work in source code form is that
+same work.
+
+ 2. Basic Permissions.
+
+ All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met. This License explicitly affirms your unlimited
+permission to run the unmodified Program. The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work. This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+ You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force. You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright. Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+ Conveying under any other circumstances is permitted solely under
+the conditions stated below. Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+ No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+ When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+ 4. Conveying Verbatim Copies.
+
+ You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+ You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+ 5. Conveying Modified Source Versions.
+
+ You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+ a) The work must carry prominent notices stating that you modified
+ it, and giving a relevant date.
+
+ b) The work must carry prominent notices stating that it is
+ released under this License and any conditions added under section
+ 7. This requirement modifies the requirement in section 4 to
+ "keep intact all notices".
+
+ c) You must license the entire work, as a whole, under this
+ License to anyone who comes into possession of a copy. This
+ License will therefore apply, along with any applicable section 7
+ additional terms, to the whole of the work, and all its parts,
+ regardless of how they are packaged. This License gives no
+ permission to license the work in any other way, but it does not
+ invalidate such permission if you have separately received it.
+
+ d) If the work has interactive user interfaces, each must display
+ Appropriate Legal Notices; however, if the Program has interactive
+ interfaces that do not display Appropriate Legal Notices, your
+ work need not make them do so.
+
+ A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit. Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+ 6. Conveying Non-Source Forms.
+
+ You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+ a) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by the
+ Corresponding Source fixed on a durable physical medium
+ customarily used for software interchange.
+
+ b) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by a
+ written offer, valid for at least three years and valid for as
+ long as you offer spare parts or customer support for that product
+ model, to give anyone who possesses the object code either (1) a
+ copy of the Corresponding Source for all the software in the
+ product that is covered by this License, on a durable physical
+ medium customarily used for software interchange, for a price no
+ more than your reasonable cost of physically performing this
+ conveying of source, or (2) access to copy the
+ Corresponding Source from a network server at no charge.
+
+ c) Convey individual copies of the object code with a copy of the
+ written offer to provide the Corresponding Source. This
+ alternative is allowed only occasionally and noncommercially, and
+ only if you received the object code with such an offer, in accord
+ with subsection 6b.
+
+ d) Convey the object code by offering access from a designated
+ place (gratis or for a charge), and offer equivalent access to the
+ Corresponding Source in the same way through the same place at no
+ further charge. You need not require recipients to copy the
+ Corresponding Source along with the object code. If the place to
+ copy the object code is a network server, the Corresponding Source
+ may be on a different server (operated by you or a third party)
+ that supports equivalent copying facilities, provided you maintain
+ clear directions next to the object code saying where to find the
+ Corresponding Source. Regardless of what server hosts the
+ Corresponding Source, you remain obligated to ensure that it is
+ available for as long as needed to satisfy these requirements.
+
+ e) Convey the object code using peer-to-peer transmission, provided
+ you inform other peers where the object code and Corresponding
+ Source of the work are being offered to the general public at no
+ charge under subsection 6d.
+
+ A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+ A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling. In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage. For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product. A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+ "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source. The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+ If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information. But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+ The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed. Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+ Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+ 7. Additional Terms.
+
+ "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law. If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+ When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it. (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.) You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+ Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+ a) Disclaiming warranty or limiting liability differently from the
+ terms of sections 15 and 16 of this License; or
+
+ b) Requiring preservation of specified reasonable legal notices or
+ author attributions in that material or in the Appropriate Legal
+ Notices displayed by works containing it; or
+
+ c) Prohibiting misrepresentation of the origin of that material, or
+ requiring that modified versions of such material be marked in
+ reasonable ways as different from the original version; or
+
+ d) Limiting the use for publicity purposes of names of licensors or
+ authors of the material; or
+
+ e) Declining to grant rights under trademark law for use of some
+ trade names, trademarks, or service marks; or
+
+ f) Requiring indemnification of licensors and authors of that
+ material by anyone who conveys the material (or modified versions of
+ it) with contractual assumptions of liability to the recipient, for
+ any liability that these contractual assumptions directly impose on
+ those licensors and authors.
+
+ All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10. If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term. If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+ If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+ Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+ 8. Termination.
+
+ You may not propagate or modify a covered work except as expressly
+provided under this License. Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+ However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+ Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+ Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License. If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+ 9. Acceptance Not Required for Having Copies.
+
+ You are not required to accept this License in order to receive or
+run a copy of the Program. Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance. However,
+nothing other than this License grants you permission to propagate or
+modify any covered work. These actions infringe copyright if you do
+not accept this License. Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+ 10. Automatic Licensing of Downstream Recipients.
+
+ Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License. You are not responsible
+for enforcing compliance by third parties with this License.
+
+ An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations. If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+ You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License. For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+ 11. Patents.
+
+ A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based. The
+work thus licensed is called the contributor's "contributor version".
+
+ A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version. For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+ In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement). To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+ If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients. "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+ If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+ A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License. You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+ Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+ 12. No Surrender of Others' Freedom.
+
+ If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all. For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+ 13. Remote Network Interaction; Use with the GNU General Public License.
+
+ Notwithstanding any other provision of this License, if you modify the
+Program, your modified version must prominently offer all users
+interacting with it remotely through a computer network (if your version
+supports such interaction) an opportunity to receive the Corresponding
+Source of your version by providing access to the Corresponding Source
+from a network server at no charge, through some standard or customary
+means of facilitating copying of software. This Corresponding Source
+shall include the Corresponding Source for any work covered by version 3
+of the GNU General Public License that is incorporated pursuant to the
+following paragraph.
+
+ Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU General Public License into a single
+combined work, and to convey the resulting work. The terms of this
+License will continue to apply to the part which is the covered work,
+but the work with which it is combined will remain governed by version
+3 of the GNU General Public License.
+
+ 14. Revised Versions of this License.
+
+ The Free Software Foundation may publish revised and/or new versions of
+the GNU Affero General Public License from time to time. Such new versions
+will be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Program specifies that a certain numbered version of the GNU Affero General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation. If the Program does not specify a version number of the
+GNU Affero General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+ If the Program specifies that a proxy can decide which future
+versions of the GNU Affero General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+ Later license versions may give you additional or different
+permissions. However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+ 15. Disclaimer of Warranty.
+
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. Limitation of Liability.
+
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+ 17. Interpretation of Sections 15 and 16.
+
+ If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+Also add information on how to contact you by electronic and paper mail.
+
+ If your software can interact with users remotely through a computer
+network, you should also make sure that it provides a way for users to
+get its source. For example, if your program is a web application, its
+interface could display a "Source" link that leads users to an archive
+of the code. There are many ways you could offer source, and different
+solutions will be better for different programs; see section 13 for the
+specific requirements.
+
+ You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU AGPL, see
+<http://www.gnu.org/licenses/>.
219 Makefile
@@ -0,0 +1,219 @@
+#!/usr/bin/make
+
+# [ Warning ] don't use make to solve dependencies !!
+#
+# we rely on ocamlbuild which already handles them ; every rule should
+# call it only once (no recursion)
+#
+# More info in build/Makefile.bld
+
+include config.make
+
+INSTALL ?= cp -u -L
+
+.PHONY: default
+default: all
+
+include build/Makefile.bld
+
+OPAOPT += "--rebuild"
+
+export
+
+##
+## STANDARD TARGETS
+##
+
+.PHONY: all
+all: $(MYOCAMLBUILD)
+ $(OCAMLBUILD) $(call target-tools,$(ALL_TOOLS)) opa-packages.stamp
+ @$(call copy-tools,$(ALL_TOOLS))
+
+.PHONY: build
+build: all
+
+.PHONY: runtime-libs
+runtime-libs: $(MYOCAMLBUILD)
+ $(OCAMLBUILD) runtime-libs.stamp
+
+$(BUILD_DIR)/bin/opa: $(MYOCAMLBUILD)
+ $(OCAMLBUILD) opa-packages.stamp $(target-tool-opa-bin)
+ @$(copy-tool-opa-bin)
+ @utils/install.sh --quiet --dir $(PWD)/$(BUILD_DIR) --ocaml-prefix $(OCAMLLIB)/../..
+
+.PHONY: opa
+opa: $(BUILD_DIR)/bin/opa
+
+.PHONY: opa-packages
+opa-packages: $(MYOCAMLBUILD)
+ $(OCAMLBUILD) opa-packages.stamp
+
+.PHONY: stdlib
+stdlib: opa-packages
+
+DISTRIB_TOOLS = opa-bin opadoc opa-plugin-builder-bin opa-plugin-browser-bin bslServerLib.ml opa-db-server opa-db-tool opa-cloud
+
+.PHONY: distrib
+distrib: $(MYOCAMLBUILD)
+ $(OCAMLBUILD) $(call target-tools,$(DISTRIB_TOOLS)) opa-packages.stamp
+ @$(call copy-tools,$(DISTRIB_TOOLS))
+
+##
+## INSTALLATION
+##
+
+.PHONY: install*
+
+STDLIB_DIR = $(PREFIX)/lib/opa/stdlib
+define install-package
+@echo "Installing into $(STDLIB_DIR)/$*.opx\r\c"
+@mkdir -p "$(STDLIB_DIR)/$*.opx/_build"
+@find "$(BUILD_DIR)/$*.opx" -maxdepth 1 ! -type d -exec $(INSTALL) {} "$(STDLIB_DIR)/$*.opx/" \;
+@$(INSTALL) $(BUILD_DIR)/$*.opx/_build/*.a "$(STDLIB_DIR)/$*.opx/_build/"
+@$(INSTALL) $(BUILD_DIR)/$*.opx/_build/*.cmi "$(STDLIB_DIR)/$*.opx/_build/"
+@$(INSTALL) $(BUILD_DIR)/$*.opx/_build/*.cmxa "$(STDLIB_DIR)/$*.opx/_build/"
+endef
+
+OPA_PACKAGES := $(shell cd stdlib && ./all_packages.sh)
+
+# Rules installing everything that has been compiled
+#
+# This doesn't rely on install rules generated by Makefile.bld ;
+# instead it assumes that what you want to install has been properly
+# put in $(BUILD_DIR)/{bin,lib/opa,share/opa}.
+#
+# This is the case of tools (because of Makefile.bld),
+# and of opa runtime libs (because build rules copy them
+# to $(BUILD_DIR)/lib/opa/static).
+# This doesn't install the other libs though, use target install-libs
+# for that
+
+install-packageopt-%:
+ $(if $(wildcard $(BUILD_DIR)/$*.opx/_build/*),$(install-package))
+
+install-package-%:
+ $(install-package)
+
+install-packages: $(addprefix install-packageopt-,$(OPA_PACKAGES))
+ @echo "Installation to $(STDLIB_DIR) done."
+
+install-all-packages: $(addprefix install-package-,$(OPA_PACKAGES))
+ @echo "Installation to $(STDLIB_DIR) done."
+
+install-bin:
+ @echo "Installing into $(PREFIX)/bin\r\c"
+ @mkdir -p $(PREFIX)/bin
+ @$(if $(wildcard $(BUILD_DIR)/bin/*),$(INSTALL) -r $(BUILD_DIR)/bin/* $(PREFIX)/bin)
+ @utils/install.sh --quiet --dir $(PREFIX) --ocamllib $(OCAMLLIB) --ocamlopt $(OCAMLOPT)
+ @echo "Installation to $(PREFIX)/bin done."
+
+install-lib:
+ @echo "Installing into $(PREFIX)/lib/opa\r\c"
+ @mkdir -p $(PREFIX)/lib/opa
+ @$(if $(wildcard $(BUILD_DIR)/lib/opa/*),$(INSTALL) -r $(BUILD_DIR)/lib/opa/* $(PREFIX)/lib/opa/)
+ @echo "Installation to $(PREFIX)/lib/opa done."
+
+install-share:
+ @echo "Installing into $(PREFIX)/share/opa\r\c"
+ @mkdir -p $(PREFIX)/share/opa
+ @$(if $(wildcard $(BUILD_DIR)/share/opa/*),$(INSTALL) -r $(BUILD_DIR)/share/opa/* $(PREFIX)/share/opa/)
+ @echo "Installation to $(PREFIX)/share/opa done."
+
+install-doc:
+ @echo "Installing into $(PREFIX)/share/doc/opa\r\c"
+ @if [ -d $(BUILD_DIR)/opadoc/doc/ ]; then \
+ mkdir -p $(PREFIX)/share/doc/opa/api; \
+ $(INSTALL) -r $(BUILD_DIR)/opadoc/doc/* $(PREFIX)/share/doc/opa/api; \
+ fi
+ @echo "Installation to $(PREFIX)/share/doc/opa done."
+
+install: install-bin install-lib install-share install-packages install-doc
+ @echo "Installation under prefix $(PREFIX) done."
+
+.PHONY: uninstall
+uninstall:
+ rm -rf $(PREFIX)/lib/opa
+ @[ ! -d $(PREFIX)/lib ] || [ -n "`ls -A $(PREFIX)/lib`" ] || rmdir $(PREFIX)/lib
+ rm -rf $(PREFIX)/share/opa
+ rm -rf $(PREFIX)/share/doc/opa
+ @[ ! -d $(PREFIX)/share ] || [ -n "`ls -A $(PREFIX)/share`" ] || rmdir $(PREFIX)/share
+ $(foreach file,$(BUILD_DIR)/bin/*,rm -f $(PREFIX)/bin/$(notdir $(file));)
+ @utils/install.sh --uninstall --dir $(PREFIX)
+ @[ ! -d $(PREFIX)/bin ] || [ -n "`ls -A $(PREFIX)/bin`" ] || rmdir $(PREFIX)/bin
+ @echo "Uninstall done."
+
+# Install our ocamlbuild-generation engine
+install-bld:
+ @mkdir -p $(PREFIX)/bin
+ @echo "#!/bin/bash -ue" > $(PREFIX)/bin/bld
+ @chmod 755 $(PREFIX)/bin/bld
+ @echo "BLDDIR=$(PREFIX)/share/opa/bld $(PREFIX)/share/opa/bld/gen_myocamlbuild.sh" >> $(PREFIX)/bin/bld
+ @echo "_build/myocamlbuild -no-plugin -j 6 \"\$$@\"" >> $(PREFIX)/bin/bld
+ @mkdir -p $(PREFIX)/share/opa/bld
+ @$(INSTALL) build/gen_myocamlbuild.sh build/myocamlbuild_*fix.ml config.sh config.mli config.ml\
+ $(PREFIX)/share/opa/bld
+
+# Install an opa wrapper with different stdlib and options (for some backwards-compatibility)
+install-qmlflat: # depends on opabsl_for_compiler, but we don't want to run ocamlbuild twice
+ @mkdir -p $(PREFIX)/bin $(PREFIX)/share/opa/mlstatebsl
+ @$(INSTALL) $(BUILD_DIR)/opabsl/mlstatebsl/opabslgen_*.opa $(PREFIX)/share/opa/mlstatebsl
+ @echo "#!/bin/bash -ue" > $(PREFIX)/bin/qmlflat
+ @chmod 755 $(PREFIX)/bin/qmlflat
+ @echo 'exec opa --no-stdlib --no-server --no-cps --no-closure --no-ei --no-constant-sharing --no-undot --separated off --value-restriction disabled --no-warn duplicateL0 --no-warn typer.warncoerce --no-warn unused --no-discard-of-unused-stdlib --no-warn pattern $$(if ! grep -qE "(^| )--no-stdlib( |$$)" <<<"$$*"; then echo $(shell sed "s%^[^# ]\+%$(PREFIX)/share/opa/mlstatebsl/opabslgen_&%; t OK; d; :OK" opabsl/mlstatebsl/bsl-sources); fi) "$$@"' \
+ >> $(PREFIX)/bin/qmlflat
+
+# installs some dev tools on top of the normal install; these should not change often
+install-all: install install-bld install-qmlflat
+ @$(INSTALL) platform_helper.sh $(PREFIX)/bin/
+
+##
+## DOCUMENTATION
+##
+# (in this section, multiple calls to ocamlbuild are tolerated)
+
+.PHONY: doc.jsbsl
+doc.jsbsl: $(MYOCAMLBUILD)
+ $(OCAMLBUILD) $@/index.html
+
+# this rules provides the doc.html target (from Makefile.bld)
+# the sed are just there to help sorting by filename-within-directory
+.PHONY: doc.odocl
+doc.odocl:
+ echo $(foreach lib,$(ALL_LIBS),$(lib-cmi-$(lib):%.cmi=%)) \
+ | sed 's# \+#\n#g' \
+ | sed 's#\(.*\)/\([^/]*\)#\1 \2#' \
+ | sort -k 2 -u \
+ | sed 's#\(.*\) \([^ ]*\)#\1/\2#' \
+ >$@
+
+.PHONY: packages-api
+packages-api: $(MYOCAMLBUILD)
+ OPAOPT="$(OPAOPT) --rebuild --api" $(OCAMLBUILD) opa-packages.stamp
+
+.PHONY: opadoc/doc
+opadoc/doc: opadoc packages-api
+ @mkdir -p $(BUILD_DIR)/$@
+ $(BUILD_DIR)/bin/opadoc -o $(BUILD_DIR)/$@ $(BUILD_DIR)/stdlib
+
+.PHONY: book
+book:
+ $(MAKE) -C doc/book
+
+.PHONY: examples
+examples: $(MYOCAMLBUILD)
+ $(OCAMLBUILD) $(call target-tools,opa-bin opa-plugin-builder-bin) opa-packages.stamp
+ $(call copy-tools,opa-bin opa-plugin-builder-bin)
+ MLSTATELIBS=`pwd`/$(BUILD_DIR) \
+ OPA="`pwd`/$(BUILD_DIR)/lib/opa/bin/opa-bin -I `pwd`/$(BUILD_DIR)" \
+ OPA_PLUGIN_BUILDER=`pwd`/$(BUILD_DIR)/lib/opa/bin/opa-plugin-builder-bin \
+ $(MAKE) -C doc/book examples
+
+.PHONY: book-clean
+book-clean:
+ $(MAKE) -C doc/book clean
+
+.PHONY: clean
+clean: book-clean
+
+.PHONY: doc
+doc: doc.html opadoc/doc book
103 README
@@ -0,0 +1,103 @@
+ OPA
+
+
+Overview
+--------
+
+Opa is a new generation of cloud development platform. It is a new programming
+language, a new web server, a new database and a new distributed execution
+engine, all of them tightly integrated to provide a great experience for cloud
+developers.
+
+This repository contains all the sources of the OPA compiler and libraries.
+
+
+Quick build instructions
+------------------------
+
+$ ./configure
+$ make
+$ sudo make install
+
+should get you there. ./configure should report any missing dependencies and
+point you to the packages you may install to fix them (although those may depend
+on your distribution).
+
+The main dependency of OPA is OCaml 3.12. In case your distribution doesn't
+provide a recent enough version, or if you miss some other dependencies, you can
+use the installation_helper.sh script, which automates the download and
+installation of our dependencies. Try
+
+$ dependencies/installation_helper.sh --help
+
+
+Directory layout
+----------------
+
+* _build: compilation target directory
+* build: build scripts and auxiliary Makefiles
+* copyright: some copyright information used in our binary package, which
+ includes external software (as obtained from the dependency installation
+ helper).
+* dependencies: contains the dependency installation helper
+* dissemination: contains helper programs to run on the cloud (transitional)
+* installer: auxiliary files used to build binary packages
+* plugins: additional OPA library modules (work in progress)
+* stdlib: the OPA standard library
+* tools: contains external checking tools; see Credits below
+* utils: some auxiliary, independent tools like bash completion, syntax
+ highlighting for popular editors, etc.
+
+The other directories contain the source of the OPA libraries, compiler, and
+tools.
+
+Files at the root of the repository:
+* *.mllib: ocamlbuild target declaration for building an ocaml lib
+* *.itarget: ocamlbuild target declaration for building a set of targets
+* install_release.sh: builds a full OPA runtime in order to make a binary
+ package
+* platform_helper.sh: some helpers to guarantee script compatibility, mostly
+ between Linux and MacOS
+* make_package.sh: builds various kinds of binary packages from the file
+ hierarchy created by install_release.sh
+
+
+The build system
+----------------
+
+The build system is based on OCamlbuild; the included build/Makefile.bld
+dynamically builds an ocamlbuild plugin and generates targets based on files
+build_libs, build_tools and build_rules.ml.
+
+See build/Makefile.bld and build_rules.ml for more information. All generated
+files are put in _build, following the same hierarchy as the source directory.
+
+
+License & Credits
+-----------------
+
+OPA is Copyright 2011, MLstate ; it is distributed under the terms of the GNU
+Affero General Public License, version 3. See file LICENSE for details.
+
+The repository opalang is currently versioning 2 external tools in tools/
+used only during the build process of Opa :
+
+* The Closure Compiler (see tools/jschecker/README for copyright information)
+* JsDoc Toolkit (see tools/jsdoc-toolkit/README.txt for copyright information)
+
+The Closure Compiler is used as a checker for the Javascript part of the sources
+of Opa, and JsDoc Toolkit is used for generating html documentation pages from this
+Javascript code.
+
+The use of these tools is transitional, and will soon be made optional.
+
+
+Contact
+-------
+
+All bug reports, feedback, comments, contributions or remarks are welcome,
+either on our website:
+ http://opalang.org
+
+or by email, to:
+ support@opalang.org
42 _tags
@@ -0,0 +1,42 @@
+# -*- conf -*- (for emacs)
+#
+# GLOBAL TAGS
+#
+# <!> PLEASE BE VERY VERY (VERY) RESTRICTED WITH DEPENDENCIES
+# if you are adding a flag 'use_something' in this file, you are probably doing something wrong
+# this file should only contain restricted traverse directives, sorted by repos, and warning-error directives
+
+# Default : do not include or traverse anything
+<**/*>: -include, -traverse
+
+# Warnings
+<**/*.ml>: warn_L, warn_Z, warn_error_A
+
+# -- from opageneral --
+
+<{utils,buildinfos}>: traverse
+
+# -- from libqml --
+
+<{pplib,libbase,compilerlib,passlib,libtrx,jslang,ocamllang,libqmlcompil,libruntime,oparuntime,database,teerex,libbsl,qmlslicer,ulex,qmlpasses,libsession}>: traverse
+
+<{libbase.{cma,cmxa},ocamlbase.top}>: use_stubs
+<ocamlbase.top>: thread, use_unix, use_str, use_zip, use_ulex
+
+# -- from qml2llvm --
+
+<{opatop,qmlflat,qmlcps,qml2ocaml,qml2js,qmljsimp,qmlcompilers,tools}>: traverse
+
+# -- from opa --
+
+<{opacapi,opalib,shared,opa,plugins,opabsl,test,opalang,passes,stdlib,ml2opa,opadoc}>: traverse
+
+# -- from appserver --
+<{appruntime,libnet,libsecurity,libtools,protocols,opasmanagers}>: traverse
+<libsecurity.*a>: use_cryptokit2, use_ssl_ext
+<appruntime.*a>: use_io
+<libnattraversal.*a>: use_miniupnpc_idl, use_natpmp_idl
+
+# --
+<{dissemination}>: traverse
+<{libirc}>: traverse
12 appruntime.mllib
@@ -0,0 +1,12 @@
+appruntime/Scheduler
+appruntime/TestSchedulerKer
+appruntime/NetAddr
+appruntime/Connection
+appruntime/NetStats
+appruntime/scheduler/SchedulerKer
+appruntime/scheduler/SchedulerJob
+appruntime/scheduler/SchedulerLog
+appruntime/scheduler/SchedulerExc
+appruntime/Epoll
+appruntime/Iocp
+appruntime/ResourceTracker
17 appruntime/_tags
@@ -0,0 +1,17 @@
+# -*- conf -*- (for emacs)
+
+true: warn_A, warn_e, warn_error_A
+
+# subdirs
+<{scheduler,io}>: traverse
+
+<**/*.{ml,mli,byte,native}>: use_libbase, use_libtrx, use_ssl, use_unix, use_zip, use_str, use_cryptokit, use_libruntime
+<**/*.{byte,native}>: use_io, use_ssl_ext
+<*.native>: use_ulex
+
+<iocp.ml>: with_mlstate_debug
+<epoll.ml>: with_mlstate_debug
+<scheduler.ml>: with_mlstate_debug
+<resourceTracker.ml>: with_mlstate_debug
+<netStats.ml>: with_mlstate_debug
+<local_manager.native>:use_ulex
226 appruntime/connection.ml
@@ -0,0 +1,226 @@
+(*
+ Copyright © 2011 MLstate
+
+ This file is part of OPA.
+
+ OPA is free software: you can redistribute it and/or modify it under the
+ terms of the GNU Affero General Public License, version 3, as published by
+ the Free Software Foundation.
+
+ OPA is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
+ more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with OPA. If not, see <http://www.gnu.org/licenses/>.
+*)
+
+(*
+ This module deals with file descriptors and synchronous operations over them.
+
+ @author Henri Binsztok
+ @author Laurent Le Brun
+ @author Frederic Ye
+ @author Cedric Soulas
+*)
+
+module MP = Mlstate_platform
+module NA = NetAddr
+
+let (|>) = InfixOperator.(|>)
+
+module Const =
+struct
+ let unix_max_pending_requests = 1024
+end
+
+type socket_type = TCP | UDP
+
+(* ============================== *)
+(* In / Out Operations *)
+(* ============================== *)
+
+exception Busy
+exception Error
+
+(* Private function *)
+let nonblocking_try f zero =
+ try f () with
+ | Unix.Unix_error((Unix.EAGAIN | Unix.EWOULDBLOCK), _, _)
+ | Ssl.Write_error (Ssl.Error_want_read | Ssl.Error_want_write)
+ | Ssl.Read_error (Ssl.Error_want_read | Ssl.Error_want_write) -> raise Busy
+ | Ssl.Read_error _
+ | Ssl.Write_error _ -> zero
+ | Unix.Unix_error((Unix.EPIPE | Unix.ECONNRESET), _, _) -> zero
+ | Unix.Unix_error(err, ctx1, ctx2) as e -> Logger.error "Unix error: %s, %s, %s\n" (Unix.error_message err) ctx1 ctx2; raise e
+ | e -> raise e
+
+(* FIXME: use FBuffers for large inputs ? *)
+let write conn ?(pos=0) buf len =
+ nonblocking_try (
+ fun () ->
+ match NA.get_type_and_fd conn with
+ | `File fd -> Unix.write fd buf pos len
+ | `Tcp fd -> Unix.send fd buf pos len []
+ | `Udp fd -> Unix.sendto fd buf pos len [] (Unix.getpeername fd)
+ | `Ssl s -> Ssl.write s buf pos len
+ ) 0
+
+(* FIXME, should that really only work for UDP sockets? *)
+let write_to conn addr ?(pos=0) buf len =
+ nonblocking_try (
+ fun () ->
+ match NA.get_type_and_fd conn with
+ | `Udp fd -> Unix.sendto fd buf pos len [] addr
+ | _ -> failwith "[Connection] write_to used on a non-UDP socket"
+ ) 0
+
+let read_aux conn tmp to_read : int * Unix.sockaddr option =
+ let no_addr res = res, None in
+ nonblocking_try (
+ fun () ->
+ match NA.get_type_and_fd conn with
+ | `File fd -> Unix.read fd tmp 0 to_read |> no_addr
+ | `Tcp fd -> Unix.recv fd tmp 0 to_read [] |> no_addr
+ | `Udp fd ->
+ let len, addr = Unix.recvfrom fd tmp 0 to_read [] in
+ len, Some addr
+ | `Ssl s -> Ssl.read s tmp 0 to_read |> no_addr
+ ) (no_addr 0)
+
+let read_more conn buf to_read =
+ let tmp = String.create to_read in
+ let nread, _ = read_aux conn tmp to_read in
+ let buf = FBuffer.add_substring buf tmp 0 nread in
+ nread, buf
+
+let read_content conn content to_read =
+ let tmp = String.create to_read in
+ let nread, _ = read_aux conn tmp to_read in
+ let content = Rcontent.content_add (String.sub tmp 0 nread) content in
+ nread, content
+
+let read_buff_length = 32768
+let read_buff = String.create read_buff_length
+
+let read_more2 conn buf =
+ let nread, _ = read_aux conn read_buff read_buff_length in
+ let () = Buffer.add_substring buf read_buff 0 nread in
+ nread, buf
+
+let read_from conn =
+ let nread, addr = read_aux conn read_buff read_buff_length in
+ let get_peer = lazy (Unix.getpeername (NA.get_fd conn)) in
+ let from = Option.default_lazy get_peer addr in
+ nread, from, (String.sub read_buff 0 nread)
+
+let read conn =
+ let nread, _ = read_aux conn read_buff read_buff_length in
+ nread, (String.sub read_buff 0 nread)
+
+let _ =
+ MP.on_windows Iocp.async_init;
+
+exception PermissionDenied
+exception UnixError
+
+(* Private function *)
+let make_socket ?(socket_flags=([] : Unix.socket_bool_option list)) socket_type =
+ let sock =
+ match socket_type with
+ | TCP ->
+ MP.platform_dependent
+ ~unix: (fun()-> Unix.socket Unix.PF_INET Unix.SOCK_STREAM 0)
+ ~windows:(fun()-> Iocp.socket())
+ () ()
+ | UDP ->
+ MP.platform_dependent
+ ~unix: (fun()-> Unix.socket Unix.PF_INET Unix.SOCK_DGRAM 0)
+ ~windows:(fun()-> assert false)
+ () ()
+ in
+ Unix.set_nonblock sock;
+ List.iter (fun opt -> Unix.setsockopt sock opt true) socket_flags;
+ sock
+
+let accept sock =
+ try
+ let (sd, sa) = Unix.accept sock in
+ match sa with
+ | Unix.ADDR_INET (host, _) ->
+ Unix.set_nonblock sd;
+ sd, host
+ | _ ->
+ Logger.error "Connection refused (unknown client)";
+ (try Unix.close sd with Unix.Unix_error _ -> ()); raise Error
+ with
+ Unix.Unix_error _ as e ->
+ Logger.error "Impossible to accept connection: (%s)" (Printexc.to_string e);
+ raise Error
+
+let connect ?(socket_type = TCP) ?socket_flags addr =
+ let sock = make_socket ?socket_flags socket_type in
+ try
+ begin
+ try Unix.connect sock addr
+ (* Use epoll to be warned when connect is finished *)
+ with Unix.Unix_error (Unix.EINPROGRESS, _, _) -> ()
+ end;
+ sock
+ with
+ | Unix.Unix_error(e, fct, arg) as exn ->
+ Logger.error "Unix error opening connection: %s for %s %s" (Unix.error_message e) fct arg;
+ raise exn
+ | e ->
+ Logger.error "Fatal error opening connection. Closing socket...";
+ Unix.close sock ;
+ raise e
+
+let listen ?(socket_type = TCP) ?socket_flags addr =
+ let sock = make_socket ?socket_flags socket_type in
+ MP.on_unixes (fun()->Unix.set_close_on_exec sock);
+ Unix.setsockopt sock Unix.SO_REUSEADDR true;
+ let _ = try Unix.bind sock addr;
+ with
+ | Unix.Unix_error(Unix.EACCES, _fct, _arg) ->
+ Logger.critical "Error binding to [%s]: Permission denied" (NA.string_of_sockaddr addr);
+ (match addr with Unix.ADDR_INET (_addr,port) when port < 1024 ->
+ Logger.critical "Hint: you probably need to be root to run servers on ports < 1024"
+ | _ -> ());
+ exit 20
+ | Unix.Unix_error(Unix.EADDRINUSE, _fct, _arg) ->
+ Logger.critical "Error binding to [%s]: Address already in use" (NA.string_of_sockaddr addr);
+ let port = match addr with Unix.ADDR_INET (_addr,port) -> port | _ -> assert false in
+ Logger.critical "Hint: a server seems to be running already on port %d, either close it or use a different port number" port;
+ exit 21
+ | Unix.Unix_error(e, fct, arg) ->
+ Logger.critical "Error binding on [%s]: %s for %s %s" (NA.string_of_sockaddr addr) (Unix.error_message e) fct arg;
+ raise UnixError
+ in
+ begin match socket_type with
+ | TCP -> Unix.listen sock Const.unix_max_pending_requests
+ | UDP -> () (* we don't call listen for UDP, binding the socket is enough *)
+ end;
+ sock
+
+(* ============================== *)
+(* Misc *)
+(* ============================== *)
+
+let close descr =
+ let fd = NA.get_fd descr in
+ (try Unix.close fd
+ with e -> Logger.error "unix close error: %s " (Printexc.to_string e);
+ );
+ (try match NA.get_type_and_fd descr with
+ | `Ssl s ->
+ Ssl.shutdown s; Unix.shutdown fd Unix.SHUTDOWN_SEND
+ | `Tcp fd -> Unix.shutdown fd Unix.SHUTDOWN_SEND
+ | `Udp _ -> () (* UDP does not require a shutdown *)
+ | `File fd -> Unix.close fd
+ with Unix.Unix_error _ -> ())
+
+let name_of_addr addr =
+ try (Unix.gethostbyaddr addr).Unix.h_name
+ with Not_found -> Unix.string_of_inet_addr addr
213 appruntime/epoll.ml
@@ -0,0 +1,213 @@
+(*
+ Copyright © 2011 MLstate
+
+ This file is part of OPA.
+
+ OPA is free software: you can redistribute it and/or modify it under the
+ terms of the GNU Affero General Public License, version 3, as published by
+ the Free Software Foundation.
+
+ OPA is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
+ more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with OPA. If not, see <http://www.gnu.org/licenses/>.
+*)
+
+(* THIS FILE HAS A DOCUMENTED MLI *)
+
+(* error reporting *)
+type error = int * string
+let error_code = fst
+let error_message = snd
+exception Error of error
+
+(* epoll descriptor *)
+type epoll_descriptor = int
+
+#<Ifstatic:MLSTATE_WINDOWS .*>
+let last_error_message _ = assert false
+let last_error_code _ = assert false
+let ep_create _ = assert false
+let ep_close _ = assert false
+let ep_in _ = assert false
+let ep_out _ = assert false
+let ep_err _ = assert false
+let ep_hup _ = assert false
+let _on_mac _ = assert false
+let on_mac = false
+#<Else>
+external last_error_message : unit -> string = "error_msg"
+external last_error_code : unit -> int = "error_value"
+external ep_create : int -> epoll_descriptor = "ep_create"
+external ep_close : epoll_descriptor -> int = "ep_close"
+external ep_in : unit -> int = "ep_EPOLLIN"
+external ep_out : unit -> int = "ep_EPOLLOUT"
+external ep_err : unit -> int = "ep_EPOLLERR"
+external ep_hup : unit -> int = "ep_EPOLLHUP"
+external _on_mac : unit -> bool = "on_mac"
+let on_mac = _on_mac ()
+#<End>
+
+(* check_ret factory *)
+let check_ret str ret =
+ if ret = -1 then
+ let message = Printf.sprintf "%s: %s" str (last_error_message ()) in
+ let code = last_error_code () in
+ Logger.error "Epoll error %d: %s" code message(* ; *)
+ (* raise (Error (code, message)) *)
+
+(* events *)
+type supported_event = In | Out | Hup | Err | Unsupported of int
+
+type event = int
+type event_mask = int
+
+let event_in, event_out, event_in_out, event_hup, event_err =
+ let u() =(ep_in(), ep_out(), (ep_in() lor ep_out()), ep_hup(), ep_err()) in
+ let z()= (0, 0, 0, 0, 0) in
+ Mlstate_platform.platform_dependent
+ ~unix:u
+ ~cygwin:z
+ ~windows:z
+ () ()
+
+let event_mask_to_list event_mask =
+ (* Frequent cases have to be memoized *)
+ if event_mask = event_in then [In] else
+ if event_mask = event_out then [Out] else
+ if event_mask = (event_in lor event_out) then [In; Out]
+ else begin
+ let f (r, l) (ie, ee) = if ((ie land r) = ie) then ((ie lxor r), ee::l) else (r, l) in
+ let rec aux (event_mask, event_list) events =
+ if event_mask = 0 then event_list
+ else (
+ match events with
+ | [] -> (Unsupported event_mask)::event_list
+ | h::t -> aux (f (event_mask, event_list) h) t
+ )
+ in
+ aux (event_mask, []) [(event_in, In); (event_out, Out); (event_hup, Hup); (event_err, Err)]
+ end
+
+
+let event_list_to_mask event_list =
+ List.fold_left
+ (fun e_mask ee ->
+ let ie =
+ match ee with
+ | In -> event_in
+ | Out -> event_out
+ | Err -> event_err
+ | Hup -> event_hup
+ | Unsupported e -> e
+ in
+ ie lor e_mask
+ ) 0 event_list
+
+(* requests *)
+
+(* low level : private *)
+#<Ifstatic:MLSTATE_WINDOWS .*>
+let ep_add _ _ _ = assert false
+let ep_del _ _ _ = assert false
+let ep_mod _ _ _ = assert false
+let ep_wait _ ~maxevents ~timeout =
+ let _ = ignore (maxevents, timeout) in
+ assert false
+#<Else>
+external ep_add : epoll_descriptor -> Unix.file_descr -> event_mask-> int = "ep_add"
+external ep_del : epoll_descriptor -> Unix.file_descr -> event_mask -> int = "ep_del"
+external ep_mod : epoll_descriptor -> Unix.file_descr -> event_mask -> int = "ep_mod"
+external ep_wait : epoll_descriptor -> maxevents : int -> timeout : int -> (Unix.file_descr * event_mask) array = "ep_wait"
+#<End>
+
+(* high level : exported *)
+
+(* The test [if int_of_filedesc fd >= 0 then] is there because weblib is also used with
+ dummy_connection (cf doc in mli). Dummy connections build negative file descriptor
+ In this case, Epoll ignore these file descriptors.
+*)
+external int_of_filedesc : Unix.file_descr -> int = "%identity"
+external filedesc_of_int : int -> Unix.file_descr = "%identity"
+external int_of_epoll_descriptor : epoll_descriptor -> int = "%identity"
+external epoll_descriptor_of : int -> epoll_descriptor = "%identity"
+
+let combine =
+ List.fold_left (lor) 0
+
+let create size =
+ Mlstate_platform.on_windows (fun()->failwith "ep_create on windows");
+ let ret = ep_create size in
+ check_ret "epoll_create" ret;
+ epoll_descriptor_of ret (* normally useless ?? *)
+
+let close ed = check_ret "epoll_close" (ep_close ed)
+
+let del epfd fd =
+ Mlstate_platform.on_windows (fun()->failwith "ep_del on windows");
+ if int_of_filedesc fd >= 0 then
+ let ret =
+ if on_mac then (
+ let _ = ep_del epfd fd event_in in
+ ep_del epfd fd event_out )
+ else
+ ep_del epfd fd 0
+ in
+ check_ret "epoll_del" ret
+
+let listen_in_out epfd ?(is_new_fd=false) fd =
+ if int_of_filedesc fd >= 0 then
+ let ret =
+ if on_mac then (
+ let _ = ep_add epfd fd event_in in
+ ep_add epfd fd event_out )
+ else (
+ if is_new_fd then
+ ep_add epfd fd event_in_out
+ else
+ ep_mod epfd fd event_in_out )
+ in
+ check_ret "listen_in_out" ret
+
+let listen_x_only x y epfd is_new_fd fd =
+ if int_of_filedesc fd >= 0 then
+ let ret =
+ if on_mac then (
+ let _ = ep_del epfd fd y in
+ ep_add epfd fd x )
+ else (
+ if is_new_fd then
+ ep_add epfd fd x
+ else
+ ep_mod epfd fd x )
+ in
+ check_ret "listen_x_only" ret
+
+let listen_in_only epfd is_new_fd fd = listen_x_only event_in event_out epfd is_new_fd fd
+let listen_out_only epfd is_new_fd fd = listen_x_only event_out event_in epfd is_new_fd fd
+
+let wait ?tout:(timeout = -1) epfd maxevents =
+ Mlstate_platform.on_windows (fun()->failwith "ep_wait on windows");
+ let a = ep_wait epfd ~maxevents ~timeout in
+ Array.map (fun (fd, events) -> (fd, event_mask_to_list events)) a
+
+module Debug =
+struct
+ (* This functions are used only for printing file descriptors and events (useful for debugging) *)
+ (* http://caml.inria.fr/pub/ml-archives/caml-list/2002/06/b0e3d11df12ca90608634197c0792939.en.html *)
+ external int_of_filedescr : Unix.file_descr -> int = "%identity"
+ external filedescr_of_int : int -> Unix.file_descr = "%identity"
+ external int_of_events : event_mask -> int = "%identity"
+ external int_of_epoll_descriptor : epoll_descriptor -> int = "%identity"
+
+ (* tests *)
+(* let test() = *)
+(* let fd = create (10) in *)
+(* add fd Unix.stdout event_in; *)
+(* add fd Unix.stdin event_in; *)
+(* let arr = wait fd 10 in *)
+(* Printf.printf "Got: %d\n" (Array.length arr) *)
+end
4 appruntime/io/_tags
@@ -0,0 +1,4 @@
+# -*- conf -*- (for emacs)
+
+
+<*.c> : c_wall, use_ssl, use_libbase
384 appruntime/io/binding_epoll.c
@@ -0,0 +1,384 @@
+/*
+ Copyright © 2011 MLstate
+
+ This file is part of OPA.
+
+ OPA is free software: you can redistribute it and/or modify it under the
+ terms of the GNU Affero General Public License, version 3, as published by
+ the Free Software Foundation.
+
+ OPA is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
+ more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with OPA. If not, see <http://www.gnu.org/licenses/>.
+*/
+/*
+ @author Laurent Le Brun (epoll)
+ @author Cedric Soulas (kqueue)
+**/
+
+#include <stdio.h>
+#include <errno.h>
+#include <string.h>
+
+#include <caml/mlvalues.h>
+#include <caml/memory.h>
+#include <caml/alloc.h>
+#include <caml/compatibility.h>
+#include <caml/fail.h>
+#include <caml/threads.h>
+
+#include "libbase/mlstate_platform.h"
+
+#define EXPORT(name,v) \
+ CAMLprim value ep_##name() \
+ { return Val_int(v); } \
+ CAMLprim value ep_has_##name(value flag) \
+ { return Val_bool((Int_val(flag) & flag) == flag); }
+
+#define SIMPLE_EXPORT(name) \
+ CAMLprim value ep_##name() \
+ { return Val_int(name); } \
+ CAMLprim value ep_has_##name(value flag) \
+ { return Val_bool((Int_val(flag) & flag) == flag); }
+
+#define DUMMY_EXPORT(name,str) \
+ CAMLprim value ep_##name(){return error_epoll_cygwin("ep",str); } \
+ CAMLprim value ep_has_##name(value flag){return error_epoll_cygwin("ep_has",str); }
+
+
+CAMLprim value error_msg()
+{
+ CAMLparam0();
+ const char *error = strerror(errno);
+ errno = 0;
+ CAMLreturn (caml_copy_string(error));
+}
+
+CAMLprim value error_value()
+{
+ CAMLparam0();
+ CAMLreturn (Val_int(errno));
+}
+
+#ifdef MLSTATE_UNIX
+
+#include <unistd.h>
+
+/* same unix standard (unistd) close for kqueue and epoll */
+value ep_close(value fd)
+{
+ CAMLparam1(fd);
+ CAMLreturn(Val_int(close(fd)));
+}
+
+#ifdef __APPLE__
+#ifdef __MACH__
+#define __APPLE__MACH__
+#endif
+#endif
+
+#ifdef __APPLE__MACH__
+
+#include <sys/types.h>
+#include <sys/event.h>
+#include <sys/time.h>
+
+CAMLprim value on_mac(){
+ CAMLparam0();
+ CAMLreturn(Val_true);
+}
+
+char* string_of_op(int op){
+ switch (op) {
+ case 0:
+ return("NULL");
+ break;
+ case EV_ADD | EV_ENABLE:
+ return("ADD");
+ break;
+ case EV_DISABLE:
+ return("DISABLE");
+ break;
+ case EV_DELETE:
+ return("DELETE");
+ break;
+ default:
+ return("UNKNOWN");
+ }
+}
+
+char* string_of_flags(int flags){
+ switch (flags) {
+ case 0:
+ return("NULL");
+ break;
+ case EVFILT_READ:
+ return("READ");
+ break;
+ case EVFILT_WRITE:
+ return("WRITE");
+ break;
+ default:
+ return("UNKNOWN");
+ }
+}
+
+value ep_create(value size)
+{
+ CAMLparam1(size);
+ CAMLreturn(Val_int(kqueue()));
+}
+
+//value epoll_op(value v_epfd, value v_fd, value v_flags, int op)
+value ep_ctl(value epfd, int op, value fd, int flags)
+{
+ CAMLparam2(epfd, fd);
+ int ret;
+ struct kevent ev_monitored;
+ struct kevent ev_check_error;
+ struct timespec nullt = {0, 0};
+
+ EV_SET(&ev_monitored, Int_val(fd), flags, op, 0, 0, 0);
+ ret = kevent(Int_val(epfd), &ev_monitored, 1, &ev_check_error, 1, &nullt);
+ if(ret==-1) printf("Net error");
+ /** TO DEBUG:
+ if ((op != EV_DISABLE) && (ev_check_error.flags & EV_ERROR)) { //It may have error with DISABLE as explained below.
+ fprintf(stderr, "%s with %s '%s %d'\n", strerror(ev_check_error.data), string_of_op(op), string_of_flags(flags), Int_val(fd));
+ //exit(EXIT_FAILURE);
+ }
+ **/
+ CAMLreturn(Val_int(ret));
+}
+
+value ep_add(value epfd, value fd, value v_flags)
+{
+ return ep_ctl(epfd, EV_ADD | EV_ENABLE, fd, Int_val(v_flags));
+}
+
+// [WARNING] Mac OS specific:
+// Unlike the Linux version, this function delete a precise filter from a filedescripor
+// and not the filedescriptor
+value ep_del(value epfd, value fd, value v_flags)
+{
+ return ep_ctl(epfd, EV_DELETE, fd, Int_val(v_flags));
+}
+
+// [WARNING] Mac OS specific:
+// Unlike the Linux version, this function do nothing
+// You have to use ep_del in conjunction with ep_add
+// The reason is that kqueue filters aren't bitmasks and there is no "modify" operation
+value ep_mod(value epfd, value fd, value v_flags)
+{
+ return(-1);
+}
+
+value ep_wait(value v_epfd, value v_maxevents, value v_timeout)
+{
+ CAMLparam3(v_epfd, v_maxevents, v_timeout);
+ CAMLlocal2(v_res, v_flags);
+ int maxevents = Int_val(v_maxevents);
+ struct kevent *evs;
+ int nb;
+
+ if (maxevents <= 0) caml_invalid_argument("kqueue wait with maxevents <= 0");
+
+ /* evs = caml_stat_alloc(maxevents); */
+ evs = malloc(maxevents * sizeof (struct kevent));
+
+ int t = Int_val(v_timeout);
+ struct timespec *ptout;
+
+ if (t<0) {
+ ptout = NULL;
+ } else {
+ time_t sec = t/1000;
+ long nano = (t-sec*1000)*1000000;
+ struct timespec tout = {sec, nano};
+ ptout = &tout;
+ }
+
+ /* fflush(stdout); */
+ nb = kevent(Int_val(v_epfd), NULL, 0, evs, maxevents, ptout);
+
+ if (nb < 0) {
+ caml_stat_free(evs);
+ int err = errno;
+ errno = 0;
+ /* fprintf(stderr, "kqueue error -1 with WAIT\n"); */
+ caml_failwith(strerror(err));
+ }
+
+ v_res = caml_alloc(nb, 0);
+
+ /* FIXME? */
+ while (--nb >= 0) {
+ value v_ev;
+ struct kevent *ev = &evs[nb];
+ if (ev->flags & EV_ERROR) {
+ fprintf(stderr, "kqueue error: \"%s\"\n", strerror(ev->data));
+ exit(EXIT_FAILURE);
+ } else {
+ //v_flags = caml_copy_int32(ev->fflags); //WHY THIS ??
+ v_ev = caml_alloc_small(2, 0);
+ Field(v_ev, 0) = Val_int(ev->ident);
+ Field(v_ev, 1) = Val_int(ev->filter); // filter like EVFILT_READ/WRITE
+ Store_field(v_res, nb, v_ev);
+ }
+
+ }
+
+ free(evs);
+ /* caml_stat_free(evs); */
+
+ CAMLreturn(v_res);
+}
+
+// kqueue & epoll equivalent
+EXPORT(EPOLLIN, EVFILT_READ); //EXPORT(EPOLLIN);
+EXPORT(EPOLLOUT, EVFILT_WRITE); //EXPORT(EPOLLOUT);
+//TODO EXPORT(EPOLLPRI);
+EXPORT(EPOLLERR, EV_ERROR);
+EXPORT(EPOLLHUP, EV_ERROR); // TODO with a hang up like event
+//TODO //EXPORT(EPOLLET);
+//TODO //EXPORT(EPOLLONESHOT);
+
+#else
+
+#include <sys/epoll.h>
+
+CAMLprim value on_mac(){
+ CAMLparam0();
+ CAMLreturn(Val_false);
+}
+
+value ep_create(value size)
+{
+ CAMLparam1(size);
+ CAMLreturn(Val_int(epoll_create(size)));
+}
+
+/* value epoll_op(value v_epfd, value v_fd, value v_flags, int op) */
+value ep_ctl(value epfd, int op, value fd, value flags)
+{
+ int ret;
+ struct epoll_event ev;
+ CAMLparam3(epfd, fd, flags);
+ ev.events = Int_val(flags);
+ ev.data.fd = Int_val(fd);
+ ret = epoll_ctl(Int_val(epfd), op, Int_val(fd), &ev);
+ CAMLreturn(Val_int(ret));
+}
+
+value ep_add(value epfd, value fd, value flags)
+{
+ return ep_ctl(epfd, EPOLL_CTL_ADD, fd, flags);
+}
+
+// [WARNING] Linux specific:
+// This function remove the filedescriptor from the epoll descriptor
+// Unlike the Mac OS version, the third argument is unused
+value ep_del(value epfd, value fd, value unused)
+{
+ return ep_ctl(epfd, EPOLL_CTL_DEL, fd, 0);
+}
+
+// [WARNING] Linux specific:
+// Unlike the Mac OS version, this function change the bitmask filter for a filedescriptor
+value ep_mod(value epfd, value fd, value flags)
+{
+ return ep_ctl(epfd, EPOLL_CTL_MOD, fd, flags);
+}
+
+value ep_wait(value v_epfd, value v_maxevents, value v_timeout)
+{
+ CAMLparam3(v_epfd, v_maxevents, v_timeout);
+ CAMLlocal2(v_res, v_flags);
+ int maxevents = Int_val(v_maxevents);
+ struct epoll_event *evs;
+ int nb;
+
+ if (maxevents <= 0) caml_invalid_argument("epoll_wait: maxevents <= 0");
+
+ /* evs = caml_stat_alloc(maxevents); */
+ evs = malloc(maxevents * sizeof (struct epoll_event));
+
+ caml_release_runtime_system();
+ nb = epoll_wait(Int_val(v_epfd), evs, maxevents, Int_val(v_timeout));
+ caml_acquire_runtime_system();
+
+ if (nb == -1) {
+ caml_stat_free(evs);
+ int err = errno;
+ errno = 0;
+ caml_failwith(strerror(err));
+ }
+
+ v_res = caml_alloc(nb, 0);
+
+ /* FIXME? */
+ while (--nb >= 0) {
+ value v_ev;
+ struct epoll_event *ev = &evs[nb];
+ //v_flags = caml_copy_int32(ev->events); WHY THIS ??
+ v_ev = caml_alloc_small(2, 0);
+ Field(v_ev, 0) = Val_int(ev->data.fd);
+ Field(v_ev, 1) = Val_int(ev->events); // v_flags replaced with ev->events
+ Store_field(v_res, nb, v_ev);
+ }
+
+ free(evs);
+ /* caml_stat_free(evs); */
+
+ CAMLreturn(v_res);
+}
+
+SIMPLE_EXPORT(EPOLLIN)
+SIMPLE_EXPORT(EPOLLOUT)
+SIMPLE_EXPORT(EPOLLHUP)
+SIMPLE_EXPORT(EPOLLERR)
+/*SIMPLE_EXPORT(EPOLLPRI)
+SIMPLE_EXPORT(EPOLLET)
+SIMPLE_EXPORT(EPOLLONESHOT)*/
+
+#endif // __APPLE__MACH__ FALSE BRANCH
+
+#endif // MLSTATE_UNIX
+
+#ifdef MLSTATE_CYGWIN
+/*
+ THIS IS A DUMMY IMPLEMENTATION FOR DEBUGGING THE COMPILATION PROCESS ONLY,
+ AND HAVING A RESTRICTED PORT ON CYGWIN
+*/
+
+#define EPOLL_MESS_ERROR "error_cygwin:%s:%s"
+#ifdef MLSTATE_WINDOWS
+#define EPOLL_MESS_ERROR "error_windows:%s:%s"
+#endif
+
+value error_epoll_cygwin(char* mess,char* fun){
+ printf(EPOLL_MESS_ERROR,mess,fun);
+ exit(1);
+ return ( (value)0 );
+}
+
+
+/* value ep_create(value size){return error_epoll_cygwin("ep_create","");}; */
+/* value ep_add(value epfd, value fd, value flags){return error_epoll_cygwin("ep_add","");}; */
+/* value ep_del(value epfd, value fd, value flags){return error_epoll_cygwin("ep_del","");}; */
+/* value ep_mod(value epfd, value fd, value flags){return error_epoll_cygwin("ep_mod","");}; */
+/* value ep_wait(value v_epfd, value v_maxevents, value v_timeout){return error_epoll_cygwin("ep_wait","");}; */
+/* value ep_close(value fd){return error_epoll_cygwin("ep_close","");}; */
+
+DUMMY_EXPORT(EPOLLIN,"epollin")
+DUMMY_EXPORT(EPOLLOUT,"epollout")
+DUMMY_EXPORT(EPOLLERR, "epollerr")
+DUMMY_EXPORT(EPOLLHUP, "epollhup")
+/*DUMMY_EXPORT(EPOLLPRI)
+DUMMY_EXPORT(EPOLLET)
+DUMMY_EXPORT(EPOLLONESHOT)*/
+
+#endif
461 appruntime/io/binding_iocp.c
@@ -0,0 +1,461 @@
+/*
+ Copyright © 2011 MLstate
+
+ This file is part of OPA.
+
+ OPA is free software: you can redistribute it and/or modify it under the
+ terms of the GNU Affero General Public License, version 3, as published by
+ the Free Software Foundation.
+
+ OPA is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
+ more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with OPA. If not, see <http://www.gnu.org/licenses/>.
+*/
+/*
+ @author Laurent Le Brun
+**/
+
+/**
+ socket : unit -> Unix.file_descr = "iocp_ml_socket"
+ async_wait : int -> int = "wait"
+ async_accept : Unix.file_descr -> int = "iocp_ml_accept"
+ async_init : unit -> unit = "async_init"
+ async_read : Unix.file_descr -> int -> int = "iocp_ml_read"
+ async_write : Unix.file_descr -> string -> int -> int = "iocp_ml_write"
+
+ get_socket : unit -> Unix.file_descr = "get_socket"
+ get_buffer : unit -> string = "get_buffer"
+
+*/
+
+
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "libbase/mlstate_platform.h"
+
+#ifdef MLSTATE_WINDOWS
+#include <Winsock2.h>
+#include <windows.h>
+#include <mswsock.h>
+#endif
+
+#include <assert.h>
+
+#include <caml/mlvalues.h>
+#include <caml/memory.h>
+#include <caml/alloc.h>
+#include <caml/compatibility.h>
+#include <caml/fail.h>
+#include <caml/unixsupport.h>
+
+//#include "iocp.h"
+
+#ifdef MLSTATE_WINDOWS
+// For some unknown reason, this macro was not available on my Windows
+#define my_offsetof(s,m) (size_t)&(((s *)0)->m)
+
+enum kind {Read, Write, Listen};
+
+struct io_context
+{
+ OVERLAPPED ovl;
+ int id;
+ int kind;
+ char *buf;
+ SOCKET sock;
+};
+
+typedef struct io_context io_context;
+
+struct connection_context
+{
+ HANDLE file;
+ SOCKET sock;
+
+ WSABUF readbuf;
+ WSABUF sendbuf;
+
+ struct io_context readctx;
+ struct io_context sendctx;
+};
+
+#define BUFFER_SIZE 4096
+
+
+void read_finished(DWORD error, DWORD transferred,
+ struct io_context *ioctx);
+void send_finished(DWORD error, DWORD transferred,
+ struct io_context *ioctx);
+void begin_send(struct connection_context *ctx);
+int async_read(SOCKET s, int len);
+int async_write(SOCKET so, char *str, int len);
+
+
+
+
+
+typedef struct sockaddr_in sockaddr_in;
+typedef struct hostent hostent;
+
+// The handle to the completion port
+HANDLE iocp;
+
+// Pointer to the system accept function
+LPFN_ACCEPTEX lpfnAcceptEx = NULL;
+
+// Warning: This is NOT thread-safe
+int count = 1;
+io_context *g_last_context = NULL;
+
+
+io_context* make_overlap(enum kind k)
+{
+ io_context *ctx = malloc(sizeof(io_context));
+ memset(ctx, 0, sizeof(*ctx));
+ ctx->id = count++;
+ ctx->kind = k;
+ return ctx;
+}
+
+
+void debug(char* toto, ...){}
+
+#define DEBUG_IOCP
+
+#ifdef DEBUG_IOCP
+#define DEBUGMESS debug
+#else
+#define DEBUGMESS printf
+#endif
+
+CAMLprim value iocp_ml_wait(value vtime)
+{
+ CAMLparam1(vtime);
+ CAMLlocal1(res);
+ int time = Long_val(vtime);
+ OVERLAPPED *ovl;
+ ULONG_PTR completionkey;
+ DWORD transferred;
+ BOOL ret;
+ int event;
+ value v_ev;
+
+ if (time < 0) time = INFINITE;
+ if (iocp == NULL) printf("iocp not initialized\n");
+ if (iocp == INVALID_HANDLE_VALUE) printf("iocp badly initialized\n");
+ debug("wait...\n");
+ ret = GetQueuedCompletionStatus(iocp, &transferred,
+ &completionkey, &ovl, time);
+
+ if(ret)
+ {
+ struct io_context *ctx = (struct io_context*)ovl;
+ g_last_context = ctx;
+ if (ctx->kind == Listen) {
+ event = 0;
+ /* async_read(ctx->sock, 20); */
+ /* async_write(ctx->sock, "Bienvenue sur cat!\n", 0); */
+ }
+ else if (ctx->kind == Read) {
+ event = 0;
+ DEBUGMESS("recv buf: `%s'\n", ctx->buf);
+ ctx->buf[transferred] = '\0';
+ /* async_read(ctx->sock, 20); */
+ /* async_write(ctx->sock, "Tu as écrit : ", 0); */
+ /* async_write(ctx->sock, ctx->buf, transferred); */
+ }
+ else if (ctx->kind == Write) {
+ event = 1;
+ DEBUGMESS("Write end.\n");
+ }else{
+ event = -1;
+ printf("Unknown kind: %d?!\n", ctx->kind);
+ }
+ res = Val_int(ctx->id);
+ }
+ else if(ovl)
+ {
+ DWORD err = GetLastError();
+ struct io_context *ctx = (struct io_context*)ovl;
+ event = -1;