Commit Graph

67 Commits

Author SHA1 Message Date
Brandon Black 7995697527 std: add IP, IPV6, IPTOS sockopt constants
Because these lists are very long in several cases and quite
varied, I opted to place them in the existing c/foo.zig files.

There are many other sets of network-related constants like this
to add over time across all the OSes.  For now I picked these
because I needed a few constants from each of these namespaces for
my own project, so I tried to flesh out these namespaces
completely as best I could, at least for basic sockopt purposes.

Note windows has some of these already defined in ws2_32 as
individual constants rather than contained in a namespacing
struct.  I'm not sure what to do with that in the long run (break
it and namespace them?), but this doesn't change the status quo
for windows in any case.
2025-09-09 17:01:20 -05:00
Elaine Gibson 8cd56e7088 haiku: restore functions mistakenly removed in e8c4e79 2025-06-05 12:30:54 +01:00
Andrew Kelley e8c4e79499 std.c reorganization
It is now composed of these main sections:
* Declarations that are shared among all operating systems.
* Declarations that have the same name, but different type signatures
  depending on the operating system. Often multiple operating systems
  share the same type signatures however.
* Declarations that are specific to a single operating system.
  - These are imported one per line so you can see where they come from,
    protected by a comptime block to prevent accessing the wrong one.

Closes #19352 by changing the convention to making types `void` and
functions `{}`, so that it becomes possible to update `@hasDecl` sites
to use `@TypeOf(f) != void` or `T != void`. Happily, this ended up
removing some duplicate logic and update some bitrotted feature
detection checks.

A handful of types have been modified to gain namespacing and type
safety. This is a breaking change.

Oh, and the last usage of `usingnamespace` site is eliminated.
2024-07-19 00:30:32 -07:00
Jacob Young 0c83fa2fd0 haiku: fix directory iteration 2024-04-08 13:20:14 -04:00
Jacob Young 5a41704f7e cbe: rewrite CType
Closes #14904
2024-03-30 20:50:48 -04:00
Jacob Young 77ff6bc656 haiku: fix poll definitions 2024-03-27 01:55:42 -04:00
Jacob Young 2dd74cd312 haiku: debitrot 2024-03-23 18:11:32 +01:00
Andrew Kelley cd62005f19 extract std.posix from std.os
closes #5019
2024-03-19 11:45:09 -07:00
Jacob Young d10c52c194 AstGen: disallow alignment on function types
A pointer type already has an alignment, so this information does not
need to be duplicated on the function type.  This already has precedence
with addrspace which is already disallowed on function types for this
reason.  Also fixes `@TypeOf(&func)` to have the correct addrspace and
alignment.
2024-03-17 03:06:17 +01:00
Andrew Kelley 0c88f927f1 std.os.termios: consolidate and correct 2024-02-12 16:21:21 -07:00
Andrew Kelley 9a64318554 std.c.NCSS: consolidate and correct 2024-02-12 15:52:13 -07:00
Andrew Kelley 5258c3caad std: add type safety to cc_t 2024-02-12 15:41:38 -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 a60f219660 std.c.MAP: use a packed struct
Same as previous commit, but for the libc interface.
2024-02-06 22:06:01 -07:00
Andrew Kelley 5f101b253e Revert "std: adding sigevent to supported platforms."
This reverts commit 23c4f55a61.
2023-07-31 11:20:39 -07:00
Andrew Kelley c6ec217e23 Revert "std.c: add find_path for haiku"
This reverts commit 1084590ec4.
2023-07-31 11:18:19 -07:00
Andrew Kelley 5d345b69ea Revert "std.fs: selfExePath haiku using constants instead"
This reverts commit e21739dd8c.
2023-07-31 11:09:28 -07:00
Andrew Kelley 1b9ffa0824 Revert "std.Thread: refining stack size from platform minimum, changes more targetted towards platform like Linux/musl (#15791)"
This reverts commit 41502c6aa5.
2023-07-31 10:54:35 -07:00
Andrew Kelley 8e9a33b82c Revert "Merge pull request #15867 from devnexen/haiku_malloc_usable_size"
This reverts commit 3ef91233ca, reversing
changes made to 2839e35d1c.
2023-07-31 10:50:48 -07:00
Andrew Kelley 95e2605d30 Revert "std.c: msghdr* struct removing prefixes to match linux."
This reverts commit 8f14431bc8.
2023-07-31 10:49:57 -07:00
Andrew Kelley 66d5f391ea Revert "std.c: fix haiku's find_path signature."
This reverts commit 9e0ac4449a.
2023-07-31 10:49:45 -07:00
David Carlier 9e0ac4449a std.c: fix haiku's find_path signature.
codePointer and subPath are not mandatory.

following up on 1084590
2023-07-01 22:20:21 -07:00
David CARLIER 8f14431bc8 std.c: msghdr* struct removing prefixes to match linux. 2023-07-01 11:14:39 -07:00
mlugg f26dda2117 all: migrate code to new cast builtin syntax
Most of this migration was performed automatically with `zig fmt`. There
were a few exceptions which I had to manually fix:

* `@alignCast` and `@addrSpaceCast` cannot be automatically rewritten
* `@truncate`'s fixup is incorrect for vectors
* Test cases are not formatted, and their error locations change
2023-06-24 16:56:39 -07:00
Eric Joldasov 50339f595a all: zig fmt and rename "@XToY" to "@YFromX"
Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me>
2023-06-19 12:34:42 -07:00
David Carlier a3eb950423 std.c: haiku also supports malloc_usable_size to benefit zig's heap 2023-05-26 12:05:19 +00:00
David CARLIER 41502c6aa5 std.Thread: refining stack size from platform minimum, changes more targetted towards platform like Linux/musl (#15791) 2023-05-25 14:32:17 -05:00
David Carlier e21739dd8c std.fs: selfExePath haiku using constants instead 2023-05-09 14:24:20 +03:00
David Carlier 1084590ec4 std.c: add find_path for haiku 2023-04-24 12:32:46 +03:00
David CARLIER 23c4f55a61 std: adding sigevent to supported platforms. 2023-04-23 19:46:43 +03: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
Andrew Kelley 50eb7983cd remove most conditional compilation based on stage1
There are still a few occurrences of "stage1" in the standard library
and self-hosted compiler source, however, these instances need a bit
more careful inspection to ensure no breakage.
2022-12-06 20:38:54 -07:00
Ryan Schneider 7f1f2e653d std.os: fix alignment of Sigaction.handler_fn
Fixes #13216
2022-11-04 08:00:50 -07:00
Ryan Liptak db80225a97 fs: Some NAME_MAX/MAX_NAME_BYTES improvements 2022-10-29 14:30:46 -07:00
Ryan Liptak 33fdc43714 std.fs: Add MAX_NAME_BYTES
Also add some NAME_MAX or equivalent definitions where necessary
2022-10-29 14:30:43 -07:00
ominitay 295451dfe5 std: Replace use of stage1 function pointers 2022-09-29 21:45:30 +03:00
zooster 4055e6055b AstGen: disallow leading zeroes in int literals and int types
This makes `0123` and `u0123` etc. illegal.

I'm now confident that this is a good change because
I actually caught two C header translation mistakes in `haiku.zig` with this.
Clearly, `0123` being octal in C (TIL) can cause confusion, and we make this easier to read by
requiring `0o` as the prefix and now also disallowing leading zeroes in integers.

For consistency and because it looks weird, we disallow it for integer types too (e.g. `u0123`).

Fixes #11963
Fixes #12417
2022-08-18 19:54:51 +03:00
Veikka Tuominen 122c76a167 Sema: allow void as an extern union field & fix invalid extern unions 2022-07-11 20:30:16 +03:00
Andrew Kelley 9c5056788f std: update bsd bits to new fn ptr semantics 2022-07-04 13:02:30 -07:00
Al Hoang db82c1b982 add constant for haiku
* re-enable zig build on haiku
2022-02-26 10:53:13 +02:00
Anthony Carrico 078aa5f7b2 Adds Linux support for POSIX file locking with fcntl
On Linux, locking fails with EAGAIN (vs. EACCES on other systems).
This commit also adds FcntlErrors for EDEADLK and ENOLCK.
2022-02-15 13:22:50 +02:00
ominitay 3dd3c5063b std.c.haiku: move Stat.crtime to Stat.birthtime 2022-02-13 20:40:44 +00:00
Isaac Freund 9f9f215305 stage1, stage2: rename c_void to anyopaque (#10316)
zig fmt now replaces c_void with anyopaque to make updating
code easy.
2021-12-19 00:24:45 -05:00
Al Hoang be541ca5e1 haiku follow up cleanup of constants 2021-11-19 22:04:09 -06:00
Al Hoang 4ec83133e9 haiku constants cleanup and update 2021-11-15 00:29:27 -06:00
Al Hoang cfb9bf59c1 update mmap flags, use defines 2021-11-15 00:29:27 -06:00
Al Hoang 59e91f4b25 ensure zig fmt 2021-11-15 00:29:27 -06:00
Al Hoang 426f54026b updates for haiku stdc
* add team_info, area_info
* update signature for get_next_image_info
* add error checks for haiku system calls
* update and cleanup of haiku constants
2021-11-15 00:29:26 -06:00
Stephen Gregoratto 506f24cac2 Set the Storage socket sizes to be system defined
Some systems (Solaris, OpenBSD, AIX) change their definitions of
sockaddr_storage to be larger than 128 bytes. This comment adds a new
constant in the `sockaddr` that defines the size for every system.

Fixes #9759
2021-09-16 13:32:55 +03:00
Andrew Kelley 0932b0d9b3 std.os reorg: regression fixes to stack_t, and std.Thread 2021-09-01 17:54:07 -07:00