pax_global_header00006660000000000000000000000064146164733610014525gustar00rootroot0000000000000052 comment=2487727655bfb8d6a511eb7886fb65bba4cfbbc7 jst-config-0.17.0/000077500000000000000000000000001461647336100136555ustar00rootroot00000000000000jst-config-0.17.0/.gitignore000066400000000000000000000000411461647336100156400ustar00rootroot00000000000000_build *.install *.merlin _opam jst-config-0.17.0/.ocamlformat000066400000000000000000000000231461647336100161550ustar00rootroot00000000000000profile=janestreet jst-config-0.17.0/CONTRIBUTING.md000066400000000000000000000044101461647336100161050ustar00rootroot00000000000000This repository contains open source software that is developed and maintained by [Jane Street][js]. Contributions to this project are welcome and should be submitted via GitHub pull requests. Signing contributions --------------------- We require that you sign your contributions. Your signature certifies that you wrote the patch or otherwise have the right to pass it on as an open-source patch. The rules are pretty simple: if you can certify the below (from [developercertificate.org][dco]): ``` Developer Certificate of Origin Version 1.1 Copyright (C) 2004, 2006 The Linux Foundation and its contributors. 1 Letterman Drive Suite D4700 San Francisco, CA, 94129 Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Developer's Certificate of Origin 1.1 By making a contribution to this project, I certify that: (a) The contribution was created in whole or in part by me and I have the right to submit it under the open source license indicated in the file; or (b) The contribution is based upon previous work that, to the best of my knowledge, is covered under an appropriate open source license and I have the right under that license to submit that work with modifications, whether created in whole or in part by me, under the same open source license (unless I am permitted to submit under a different license), as indicated in the file; or (c) The contribution was provided directly to me by some other person who certified (a), (b) or (c) and I have not modified it. (d) I understand and agree that this project and the contribution are public and that a record of the contribution (including all personal information I submit with it, including my sign-off) is maintained indefinitely and may be redistributed consistent with this project or the open source license(s) involved. ``` Then you just add a line to every git commit message: ``` Signed-off-by: Joe Smith ``` Use your real name (sorry, no pseudonyms or anonymous contributions.) If you set your `user.name` and `user.email` git configs, you can sign your commit automatically with git commit -s. [dco]: http://developercertificate.org/ [js]: https://opensource.janestreet.com/ jst-config-0.17.0/LICENSE.md000066400000000000000000000021461461647336100152640ustar00rootroot00000000000000The MIT License Copyright (c) 2019--2024 Jane Street Group, LLC Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. jst-config-0.17.0/Makefile000066400000000000000000000004031461647336100153120ustar00rootroot00000000000000INSTALL_ARGS := $(if $(PREFIX),--prefix $(PREFIX),) default: dune build install: dune install $(INSTALL_ARGS) uninstall: dune uninstall $(INSTALL_ARGS) reinstall: uninstall install clean: dune clean .PHONY: default install uninstall reinstall clean jst-config-0.17.0/discover/000077500000000000000000000000001461647336100154735ustar00rootroot00000000000000jst-config-0.17.0/discover/discover.ml000066400000000000000000000120031461647336100176370ustar00rootroot00000000000000open Base module C = Configurator.V1 let eventfd_code = {| #include int main() { int fd = eventfd(0, 0); return 0; } |} ;; let posix_timers_code = {| #include int main() { struct timespec ts; clock_gettime(CLOCK_REALTIME, &ts); clock_settime(CLOCK_REALTIME, &ts); clock_getres(CLOCK_REALTIME, &ts); return 0; } |} ;; let clock_getcpuclockid_code = {| #include int main() { clock_getcpuclockid(0, CLOCK_REALTIME); return 0; } |} ;; type posix_timers = | Available of { need_lrt : bool ; getcpuclockid : bool } | Not_available let timespec_code = {| #include int main() { struct timespec ts; timespec_get(&ts, TIME_UTC); return 0; } |} ;; let timerfd_code = {| #include int main() { timerfd_create(0, 0); return 0; } |} ;; let wordexp_code = {| #include int main() { wordexp_t w; wordexp("", &w, 0); return 0; } |} ;; let thread_id_code ~thread_id_method ~thread_id_header = Printf.sprintf {| #define JSC_THREAD_ID_METHOD %d #include "%s" int main () { GET_THREAD_ID; return 0; } |} thread_id_method thread_id_header ;; let memfd_code = {| #define _GNU_SOURCE #include int main() { memfd_create("foo", 0); return 0; } |} ;; let msg_nosignal_code = {| #include #include int main() { send(0, "", 0, MSG_NOSIGNAL); return 0; } |} ;; let so_nosigpipe_code = {| #include #include int main() { send(0, "", 0, SO_NOSIGPIPE); return 0; } |} ;; let fdatasync_code = {| #include int main() { fdatasync(0); return 0; } |} let thread_cputime_code = {| #include #include int main() { clockid_t clock; pthread_getcpuclockid(pthread_self(), &clock); return 0; } |} ;; let recvmmsg_code = {| #define _GNU_SOURCE #include int main () { recvmmsg(0, 0, 0, 0, 0); return 0; } |} ;; let mkostemp_code = {| #define _GNU_SOURCE #include int main () { mkostemp("", 0); return 0; } |} ;; let pthread_np = {| #define _GNU_SOURCE #include #include #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__APPLE__) #include #endif int main() { pthread_t tid; cpu_set_t cpuset; tid = pthread_self(); pthread_getaffinity_np(tid, sizeof(cpu_set_t), &cpuset); return 0; } |} ;; let readdir_dtype_code = {| #include int main() { int i = DT_BLK; return 0; } |} ;; let () = C.main ~name:"config_h" (fun c -> let posix_timers = C.c_test c posix_timers_code in let clock_getcpuclockid = C.c_test c clock_getcpuclockid_code in let thread_id_method = let thread_id_header = Stdlib.Filename.concat (Stdlib.Sys.getcwd ()) "thread_id.h" in List.find [ 1; 2 ] ~f:(fun thread_id_method -> C.c_test c (thread_id_code ~thread_id_method ~thread_id_header)) |> Option.value ~default:(-1) in let linux = let system = C.ocaml_config_var_exn c "system" in (* TODO: "uname -s" should be used instead *) (* Possible values for this field: linux, linux_elf, linux_eabi, ... *) String.is_prefix system ~prefix:"linux" || String.equal system "elf" in let simple_vars = List.map ~f:(fun (v, code, c_flags, link_flags) -> v, C.C_define.Value.Switch (C.c_test c code ~c_flags ~link_flags)) [ "EVENTFD", eventfd_code, [], [] ; "TIMESPEC", timespec_code, [ "-std=c11" ], [] ; "TIMERFD", timerfd_code, [], [] ; "WORDEXP", wordexp_code, [], [] ; "MEMFD", memfd_code, [], [] ; "MSG_NOSIGNAL", msg_nosignal_code, [], [] ; "SO_NOSIGPIPE", so_nosigpipe_code, [], [] ; "FDATASYNC", fdatasync_code, [], [] ; "RECVMMSG", recvmmsg_code, [], [] ; "THREAD_CPUTIME", thread_cputime_code, [], [ "-lpthread" ] ; "PTHREAD_NP", pthread_np, [], [ "-lpthread" ] ; "MKOSTEMP", mkostemp_code, [], [] ; "READDIR_DTYPE", readdir_dtype_code, [], [] ] in let rlimit_vars = if C.c_test c "#include \nint main() { return 0; }" then C.C_define.import c ~includes:[ "sys/resource.h" ] [ "RLIMIT_AS", Switch; "RLIMIT_NICE", Switch ] else [ "RLIMIT_AS", Switch false; "RLIMIT_NICE", Switch false ] in let ocaml_vars = C.C_define.import c ~includes:[ "caml/config.h" ] [ "ARCH_BIG_ENDIAN", Switch; "ARCH_SIXTYFOUR", Switch ] in let vars = List.concat [ rlimit_vars ; ocaml_vars ; simple_vars ; [ "POSIX_TIMERS", Switch posix_timers ; "CLOCK_GETCPUCLOCKID", Switch clock_getcpuclockid ; "THREAD_ID_METHOD", Int thread_id_method ; "LINUX_EXT", Switch linux ] ] in let jsc_vars = List.map vars ~f:(fun (name, v) -> "JSC_" ^ name, v) in C.C_define.gen_header_file c ~fname:"config.h" jsc_vars) ;; jst-config-0.17.0/discover/dune000066400000000000000000000001671461647336100163550ustar00rootroot00000000000000(executables (modes byte exe) (names discover) (libraries base dune-configurator) (preprocess (pps ppx_assert))) jst-config-0.17.0/dune-project000066400000000000000000000000211461647336100161700ustar00rootroot00000000000000(lang dune 3.11) jst-config-0.17.0/jst-config.opam000066400000000000000000000020731461647336100166000ustar00rootroot00000000000000opam-version: "2.0" version: "v0.17.0" maintainer: "Jane Street developers" authors: ["Jane Street Group, LLC"] homepage: "https://github.com/janestreet/jst-config" bug-reports: "https://github.com/janestreet/jst-config/issues" dev-repo: "git+https://github.com/janestreet/jst-config.git" doc: "https://ocaml.janestreet.com/ocaml-core/latest/doc/jst-config/index.html" license: "MIT" build: [ ["dune" "build" "-p" name "-j" jobs] ] depends: [ "ocaml" {>= "5.1.0"} "base" {>= "v0.17" & < "v0.18"} "ppx_assert" {>= "v0.17" & < "v0.18"} "dune" {>= "3.11.0"} "dune-configurator" ] available: arch != "arm32" & arch != "x86_32" synopsis: "Compile-time configuration for Jane Street libraries" description: " Defines compile-time constants used in Jane Street libraries such as Base, Core, and Async. This package has an unstable interface; it is intended only to share configuration between different packages from Jane Street. Future updates may not be backward-compatible, and we do not recommend using this package directly. " jst-config-0.17.0/src/000077500000000000000000000000001461647336100144445ustar00rootroot00000000000000jst-config-0.17.0/src/dune000066400000000000000000000004501461647336100153210ustar00rootroot00000000000000(rule (targets config.h) (deps (:first_dep ../discover/discover.exe) thread_id.h) (action (run %{first_dep}))) (install (section lib) (files (config.h as config.h) (thread_id.h as thread_id.h))) (library (name config_h) (public_name jst-config) (preprocess no_preprocessing)) jst-config-0.17.0/src/thread_id.h000066400000000000000000000012401461647336100165350ustar00rootroot00000000000000/* This file is used by both unix_stubs.c and config/discover.ml */ #if !defined(JSC_THREAD_ID_METHOD) #warning "JSC_THREAD_ID_METHOD not defined" #endif #if JSC_THREAD_ID_METHOD == 1 #include #include #define GET_THREAD_ID syscall(SYS_gettid) #elif JSC_THREAD_ID_METHOD == 2 #include /* Advice from Philip Guenther on the ocaml-core mailing list is that we need to prototype * this ourselves :( * See: https://groups.google.com/forum/#!topic/ocaml-core/51knlnuJ8MM */ extern pid_t getthrid(void); #define GET_THREAD_ID getthrid() #elif !(JSC_THREAD_ID_METHOD == -1) #warning "Unknown JSC_THREAD_ID_METHOD value" #endif