Commit graph

109 commits

Author SHA1 Message Date
Veikka Tuominen
5e1ccd96e5 remove std.Ini 2024-06-02 13:03:29 -04:00
Andrew Kelley
f47824f24d std: restructure child process namespace 2024-05-26 09:31:55 -07:00
Jonathan Marler
a96b78c170 add std.zip and support zip files in build.zig.zon
fixes #17408

Helpful reviewers/testers include Joshe Wolfe, Auguste Rame, Andrew
Kelley and Jacob Young.

Co-authored-by: Joel Gustafson <joelg@mit.edu>
2024-05-03 16:58:53 -04:00
Travis Staloch
8af59d1f98 ComptimeStringMap: return a regular struct and optimize
this patch renames ComptimeStringMap to StaticStringMap, makes it
accept only a single type parameter, and return a known struct type
instead of an anonymous struct.  initial motivation for these changes
was to reduce the 'very long type names' issue described here
https://github.com/ziglang/zig/pull/19682.

this breaks the previous API.  users will now need to write:
`const map = std.StaticStringMap(T).initComptime(kvs_list);`

* move `kvs_list` param from type param to an `initComptime()` param
* new public methods
  * `keys()`, `values()` helpers
  * `init(allocator)`, `deinit(allocator)` for runtime data
  * `getLongestPrefix(str)`, `getLongestPrefixIndex(str)` - i'm not sure
     these belong but have left in for now incase they are deemed useful
* performance notes:
  * i posted some benchmarking results here:
    https://github.com/travisstaloch/comptime-string-map-revised/issues/1
  * i noticed a speedup reducing the size of the struct from 48 to 32
    bytes and thus use u32s instead of usize for all length fields
  * i noticed speedup storing KVs as a struct of arrays
  * latest benchmark shows these wall_time improvements for
    debug/safe/small/fast builds: -6.6% / -10.2% / -19.1% / -8.9%. full
    output in link above.
2024-04-22 15:31:41 -07:00
Andrew Kelley
cd62005f19 extract std.posix from std.os
closes #5019
2024-03-19 11:45:09 -07:00
Andrew Kelley
aa852f737b improve documentation in std
A lot of these "shorthand" doc comments were redundant, low quality
filler content. Better to let the actual modules speak for themselves
with top level doc comments rather than trying to document their
aliases.
2024-03-10 18:13:30 -07:00
Andrew Kelley
a2e87aba66 rearrange std.zig
This frees up std.zig.fmt to be used for the implementation of `zig
fmt`.
2024-02-26 21:35:33 -07:00
Andrew Kelley
7680c5330c some API work on std.c, std.os, std.os.wasi
* std.c: consolidate some definitions, making them share code. For
  example, freebsd, dragonfly, and openbsd can all share the same
  `pthread_mutex_t` definition.
* add type safety to std.c.O
  - this caught a bug where mode flags were incorrectly passed as the
    open flags.
* 3 fewer uses of usingnamespace keyword
* as per convention, remove purposeless field prefixes from struct field
  names even if they have those prefixes in the corresponding C code.
* fix incorrect wasi libc Stat definition
* remove C definitions from incorrectly being in std.os.wasi
* make std.os.wasi definitions type safe
* go through wasi native APIs even when linking libc because the libc
  APIs are problematic and wasteful
* don't expose WASI definitions in std.posix
* remove std.os.wasi.rights_t.ALL: this is a footgun. should it be all
  future rights too? or only all current rights known? both are
  the wrong answer.
2024-02-11 13:38:55 -07:00
Andrew Kelley
32f30399e5
Merge pull request #18867 from e4m2/random
std.rand: Move to std.Random
2024-02-09 13:42:04 -08:00
Andrew Kelley
54bbc73f85
Merge pull request #18712 from Vexu/std.options
std: make options a struct instance instead of a namespace
2024-02-09 13:38:42 -08:00
e4m2
9af077d71e std.rand: Move to std.Random 2024-02-08 14:43:20 +01:00
Ali Chraghi
be32ae0534 std: add gpu namespace 2024-02-05 11:55:14 +03:30
Veikka Tuominen
b0bea72588 remove std.event 2024-02-01 15:22:36 +02:00
Veikka Tuominen
8d11ade6a7 std: change return type of wasiCwd
`fd_t` is not declared on freestanding so returning a `Dir` causes an error.
2024-02-01 15:22:36 +02:00
Veikka Tuominen
220d3264c9 std: make options a struct instance instead of a namespace 2024-02-01 15:22:36 +02:00
Veikka Tuominen
c085c6ecdd std: remove meta.globalOption 2024-01-27 13:56:32 -08:00
Andrew Kelley
67d48b94d6 std.Target: flatten 2024-01-01 17:51:18 -07:00
Andrew Kelley
142471fcc4 zig build system: change target, compilation, and module APIs
Introduce the concept of "target query" and "resolved target". A target
query is what the user specifies, with some things left to default. A
resolved target has the default things discovered and populated.
In the future, std.zig.CrossTarget will be rename to std.Target.Query.
Introduces `std.Build.resolveTargetQuery` to get from one to the other.

The concept of `main_mod_path` is gone, no longer supported. You have to
put the root source file at the module root now.

* remove deprecated API
* update build.zig for the breaking API changes in this branch
* move std.Build.Step.Compile.BuildId to std.zig.BuildId
* add more options to std.Build.ExecutableOptions, std.Build.ObjectOptions,
  std.Build.SharedLibraryOptions, std.Build.StaticLibraryOptions, and
  std.Build.TestOptions.
* remove `std.Build.constructCMacro`. There is no use for this API.
* deprecate `std.Build.Step.Compile.defineCMacro`. Instead,
  `std.Build.Module.addCMacro` is provided.
  - remove `std.Build.Step.Compile.defineCMacroRaw`.
* deprecate `std.Build.Step.Compile.linkFrameworkNeeded`
  - use `std.Build.Module.linkFramework`
* deprecate `std.Build.Step.Compile.linkFrameworkWeak`
  - use `std.Build.Module.linkFramework`
* move more logic into `std.Build.Module`
* allow `target` and `optimize` to be `null` when creating a Module.
  Along with other fields, those unspecified options will be inherited
  from parent `Module` when inserted into an import table.
* the `target` field of `addExecutable` is now required. pass `b.host`
  to get the host target.
2024-01-01 17:51:18 -07:00
Nameless
e11a839760
std.http: use loadDefaultProxies in compiler 2023-10-21 20:52:58 -05:00
Nameless
0eef21d8ec
std.http.Client: add option to disable https
std_options.http_connection_pool_size removed in favor of

```
client.connection_pool.resize(client.allocator, size);
```

std_options.http_disable_tls will remove all https capability from
std.http when true. Any https request will error with
`error.TlsInitializationFailed`.

Solves #17051.
2023-10-21 20:52:58 -05:00
Eric Joldasov
1f6d82ec01 std.cstr: remove deprecated namespace
Followup to 0a868dacdd .

Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me>
2023-10-10 02:08:03 +03:00
Ryan Liptak
c9613e3d5c ComptimeStringMap: Add version that takes an equality function
This will allow users to construct e.g. a ComptimeStringMap that uses case-insensitive ASCII comparison.

Note: the previous ComptimeStringMap API is unchanged (i.e. this does not break any existing code).
2023-09-14 11:03:15 -07:00
Wooster
f33bb0228b
std: clean up top-level namespaces documentation
This cleans up existing documentation, adds a bit more, and fixes some
typos too.
2023-09-08 21:59:25 +03:00
Jay Petacat
26b03ca823 std: Move TailQueue alias to correct namespace
This fixes a mistake in PR #16996.
2023-08-28 17:41:37 -07:00
Jay Petacat
ff61c42879 std: Rename TailQueue to DoublyLinkedList
`TailQueue` was implemented as a doubly-linked list, but named after an
abstract data type. This was inconsistent with `SinglyLinkedList`, which
can be used to implement an abstract data type, but is still named after
the implementation. Renaming `TailQueue` to `DoublyLinkedList` improves
consistency between the two type names, and should help discoverability.

`TailQueue` is now a deprecated alias of `DoublyLinkedList`.

Related to issues #1629 and #8233.
2023-08-27 20:57:46 -07:00
Loris Cro
373e48c983
autodoc: new layout (#16715)
* autodoc: init guide TOC work

* autodoc: working guides toc navigation

* autodoc: more improvements

* autodoc: ui refinements

* autodoc: new layout and init descriptions for namespaces in std.zig
2023-08-06 18:12:05 +02:00
Josh Wolfe
8924f81d8c
std.json: Unify stringify and writeStream (#16405) 2023-07-21 19:56:46 -04:00
Motiejus Jakštys
e0dd20b02e
add BoundedArrayAligned (#14580)
This is useful for creating byte buffers of actually-different-things.
Copied the argument order from `Allocator.alignedAlloc`

I noted that `ArrayListAligned` is going out of it's way to not set the
alignment at comptime when it is not specified. However, I was not able
to do that the same way here, and good people on IRC, @ifreund in
particular (thanks!) assured me that

    [N]T align(@alignOf(T))

is equivalent to

    [N]T
2023-03-17 17:50:25 +01:00
Frank Denis
5a12d00708
Move std.crypto.config options to std.options (#14906)
Options have been moved to a single namespace.
2023-03-14 06:40:23 +00:00
Nameless
524e0cd987
std.http: rework connection pool into its own type 2023-03-09 14:55:31 -06:00
Andrew Kelley
aaaaab9ec2 std.process.Child: remove pid and handle, add id
Previously, this API had pid, to be used on POSIX systems, and handle,
to be used on Windows.

This commit unifies the API, defining an Id type that is either the pid
or the HANDLE depending on the target OS.

This commit also prepares for the future by allowing one to import via
`std.process.Child` which is the fully qualified namespace that I intend
to migrate to in the future.
2023-03-03 07:49:05 -05:00
dweiller
c7c35bf9e6 std.RingBuffer: add (non-concurrent) RingBuffer implementation 2023-02-21 12:58:34 +11:00
Jonathan Marler
dafefe9c9d use std_options for keep_sigpipe and existence of SIG.PIPE to check for support 2023-02-18 11:49:15 -07:00
ominitay
3c8d968194 fmt: Make default_max_depth configurable 2023-02-01 21:43:36 +02:00
Andrew Kelley
13a9616540 std.Build: add deprecated declarations
These declarations are now aliases of their new APIs and marked as
deprecated via doc comments:
 * std.build.Builder
 * std.build
 * std.Build.LibExeObjStep
2023-01-31 15:09:35 -07:00
Andrew Kelley
16cdd1297e rename std.Build.LibExeObjStep to std.Build.CompileStep
This matches the nomenclature internally: a Compilation is the main type
that represents a single invokation of the compiler.
2023-01-31 15:09:35 -07:00
Andrew Kelley
36e2d992dd combine std.build and std.build.Builder into std.Build
I've been wanting to do this for along time.
2023-01-31 15:09:35 -07:00
Andrew Kelley
585b9970ef add std.tar for tar file unpacking 2023-01-11 15:39:48 -08:00
Felix "xq" Queißner
e7c109329d Renames Url.zig to Uri.zig 2023-01-06 17:56:05 -07:00
Veikka Tuominen
f83834993e std: collect all options under one namespace 2023-01-05 02:31:29 -07:00
Andrew Kelley
5b8b5f2505 add url parsing to the std lib 2023-01-02 16:57:15 -07:00
Andrew Kelley
cd0d514643 remove the experimental std.x namespace
Playtime is over. I'm working on networking now.
2023-01-02 16:57:15 -07:00
Evin Yulo
3367f19078 Make std.tz namespace accessible
Closes #13978
2022-12-18 01:41:56 +02:00
Andrew Kelley
dd547f06c6 std.build: extract steps to separate files
There are intended to be no functional changes in this commit.
2022-12-11 12:48:17 -07:00
Meghan
3a64693db3
std: add http definitions for Method and Status (#10661) 2022-05-11 15:43:18 -04:00
Andrew Kelley
711bf55eaa std: bring back SegmentedList
I want to use it for the self-hosted compiler.
2022-04-20 05:31:24 -07:00
kprotty
7284eb22dc treap: initial implementation 2022-04-15 15:26:51 -05:00
tecanec
3beef3945c
std: SIMD utility functions
This file contains a collections of functions that may be useful for SIMD, such as generating a vector with a linear range of numbers starting at zero, joining two vectors together, getting the index of the first true in a vector of bools, etc.
2022-03-27 11:28:44 +03:00
Jens Goldberg
9a56435666 tz parsing reader interface, test thicc files, and exclude tzif 2021-12-31 17:17:49 +00:00
Jens Goldberg
e4672c95f1 Actually expose the tz file 2021-12-30 18:20:29 +00:00