Rename picnit to nitpm and intro 4 main new features.
### Install package versions
Install specific versions of a package using the following command:
~~~
nitpm install gamnit=0.5
~~~
The version string (the `0.5` in the above example) must be a Git branch or tag, it will be used when cloning the package locally. The package will be downloaded to `~/.local/lib/nit/gamnit=0.5/`, allowing multiple versions of the same package to be installed concurrently.
### Dependencies in package.ini
Packages should now declare dependencies to other nitpm packages in the `package.ini` at the `import` key:
~~~
[package]
name=my_package
import=hello_nitpm, gamnit=0.5
~~~
The dependencies can then be installed automatically with `nitpm install` from the root of the package.
Nit tools read the local `package.ini` to redirect imports of `gamnit` inside this package to this specific version. So for `my_package` described above, all references to `gamnit` will use the implementation `gamnit=0.5`.
### Recursive installation
nitpm installs dependencies recursively, so if `gamnit` requires `glesv2`, after an explicit command to install `gamnit` nitpm will also install `glesv2`. This implementation is minimal, it could be improved by precalculating all dependencies and asking for confirmation.
### Customizable install directory
You can now use the env var `NITPM_PATH` to set the path where libraries are installed. This will override the default path at `~/.local/lib/nit/`.
### Others
* `nitpm uninstall` can uninstall many packages at once, it is safer and it accepts the -f option to skip the confirmation.
* `nitpm list` lists packages in alphabetical order.
Pull-Request: #2622
Reviewed-by: Romain Chanoir <romain.chanoir@viacesi.fr>
Reviewed-by: Jean Privat <jean@pryen.org>
# See the License for the specific language governing permissions and
# limitations under the License.
-# Data transfer with URL syntax
+# Data transfer powered by the native curl library
#
# Download or upload over HTTP with `CurlHTTPRequest` and send emails with `CurlMail`.
module curl
# Set the user agent for all following HTTP requests
var user_agent: nullable String is writable
+ # Set the Unix domain socket path to use
+ #
+ # When not null, enables using a Unix domain socket
+ # instead of a TCP connection and DNS hostname resolution.
+ var unix_socket_path: nullable String is writable
+
# Execute HTTP request
#
# By default, the response body is returned in an instance of `CurlResponse`.
if not err.is_ok then return answer_failure(err.to_i, err.to_s)
end
+ var unix_socket_path = unix_socket_path
+ if unix_socket_path != null then
+ err = self.curl.native.easy_setopt(new CURLOption.unix_socket_path, unix_socket_path)
+ if not err.is_ok then return answer_failure(err.to_i, err.to_s)
+ end
+
# Callbacks
err = self.curl.native.register_callback_header(callback_receiver)
if not err.is_ok then return answer_failure(err.to_i, err.to_s)
if obj isa Int then return native_setopt_int(opt, obj)
if obj == true then return native_setopt_int(opt, 1)
if obj == false then return native_setopt_int(opt, 0)
- if obj isa String then return native_setopt_string(opt, obj)
+ if obj isa String then return native_setopt_string(opt, obj.to_cstring)
if obj isa FileWriter then return native_setopt_file(opt, obj._file.as(not null))
if obj isa CURLSList then return native_setopt_slist(opt, obj)
return once new CURLCode.unknown_option
private fun native_setopt_slist(opt: CURLOption, list: CURLSList): CURLCode `{ return curl_easy_setopt( self, opt, list); `}
# Internal method to set options to CURL using String parameter.
- private fun native_setopt_string(opt: CURLOption, str: String): CURLCode import String.to_cstring `{
- char *rStr = String_to_cstring(str);
- return curl_easy_setopt( self, opt, rStr);
+ private fun native_setopt_string(opt: CURLOption, str: CString): CURLCode `{
+ return curl_easy_setopt( self, opt, str);
`}
# Request Chars internal information from the CURL session
return answ.item.to_s
end
- # Internal method used to get String object information initially knowns as C Chars type
+ # Internal method used to get String object information initially known as C Chars type
private fun native_getinfo_chars(opt: CURLInfoChars, res: Ref[CString]): CURLCode
import Ref[CString].item= `{
char *r;
# new `{ return CURLOPT_SSH_KEYFUNCTION; `}
# new `{ return CURLOPT_SSH_KEYDATA; `}
+ # TELNET Options
+
+# new `{ return CURLOPT_TELNETOPTIONS; `}
+
# Other Options
# new `{ return CURLOPT_PRIVATE; `}
# new `{ return CURLOPT_NEW_FILE_PERMS; `}
# new `{ return CURLOPT_NEW_DIRECTORY_PERMS; `}
- # TELNET Options
-
-# new `{ return CURLOPT_TELNETOPTIONS; `}
+ # Set the Unix domain socket
+ new unix_socket_path `{ return CURLOPT_UNIX_SOCKET_PATH; `}
end
# Download or redownload
rm -rf bdwgc
-git clone -b android https://github.com/xymus/bdwgc.git || exit 1
+git clone --depth=1 -b android https://github.com/xymus/bdwgc.git || exit 1
# Setup libatomic_ops too
cd bdwgc || exit 1
git submodule init || exit 1
-git submodule update || exit 1
+git submodule update --depth=1 || exit 1
self.header.add_decl """
struct catch_stack_t {
int cursor;
- jmp_buf envs[100];
+ int currentSize;
+ jmp_buf *envs;
};
-extern struct catch_stack_t catchStack;
+extern __thread struct catch_stack_t catchStack;
"""
end
v.add_decl("int glob_argc;")
v.add_decl("char **glob_argv;")
v.add_decl("val *glob_sys;")
- v.add_decl("struct catch_stack_t catchStack;")
+ v.add_decl("__thread struct catch_stack_t catchStack = \{-1, 0, NULL\};")
if self.modelbuilder.toolcontext.opt_typing_test_metrics.value then
for tag in count_type_test_tags do
v.add "#endif"
v.add("glob_argc = argc; glob_argv = argv;")
- v.add("catchStack.cursor = -1;")
v.add("initialize_gc_option();")
v.add "initialize_nitni_global_refs();"
redef fun stmt(v)
do
if self.n_catch != null then
+ v.add("if(catchStack.currentSize == 0) \{")
+ v.add(" catchStack.cursor = -1;")
+ v.add(" catchStack.currentSize = 100;")
+ v.add(" catchStack.envs = malloc(sizeof(jmp_buf)*100);")
+ v.add("\} else if(catchStack.cursor == catchStack.currentSize - 1) \{")
+ v.add(" catchStack.currentSize *= 2;")
+ v.add(" catchStack.envs = realloc(catchStack.envs, sizeof(jmp_buf)*catchStack.currentSize);")
+ v.add("\}")
v.add("catchStack.cursor += 1;")
v.add("if(!setjmp(catchStack.envs[catchStack.cursor]))\{")
v.stmt(self.n_block)
--- /dev/null
+caught 100000 aborts
+caught 100000 aborts
+caught 100000 aborts
+caught 100000 aborts
+caught 100000 aborts
+caught 100000 aborts
+caught 100000 aborts
+caught 100000 aborts
+caught 100000 aborts
+caught 100000 aborts
--- /dev/null
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Test the multi-threaded dynamic `do catch` mechanism
+import pthreads
+
+# A Thread that does a lot of `do catch`
+class CatchThread
+ super Thread
+
+ var x = 100000
+ var caught = 0
+
+ redef fun main do
+ do
+ rec_do_catch
+ catch
+ end
+ print "caught {caught} aborts"
+ return null
+ end
+
+ fun rec_do_catch do
+ do
+ x -= 1
+ if x > 0 then
+ rec_do_catch
+ else
+ abort
+ end
+ catch
+ self.caught += 1
+ abort
+ end
+ end
+end
+
+var ts = new Array[CatchThread]
+var nb_threads = 10
+for i in [0..nb_threads[ do
+ var t = new CatchThread
+ ts.add(t)
+ t.start
+end
+for t in ts do t.join