Commit Graph

185 Commits

Author SHA1 Message Date
mlugg
474d17c13a
std.c: do not use usingnamespace to define getcontext
Eliminates one more usage of `usingnamespace` from the standard library.
2024-03-08 08:02:44 +00:00
Michael Dusan
70fbafacf2 std: fix macos x86_64 to link stat$INODE64
- restricted similar $INODE64 symbols to macos x86_64 only
- minor cleanup and updated comments

closes #11386
2024-02-24 13:09:03 -08:00
Michael Dusan
50cdb75034
std.os.termios: fix tc flag types for macos
macos uses 64-bits for the flag types.

closes #18942
2024-02-15 02:08:18 -05:00
Andrew Kelley
5f92558290 std.posix.termios: bring V back
In d7563a7753, I misunderstood what `cc_t`
was supposed to do. Those V enum values are indices into the array.
2024-02-13 20:10:32 -08:00
Andrew Kelley
e1ab57337f std.c.speed_t: consolidate common across os 2024-02-12 21:53:54 -07:00
Andrew Kelley
ae107cf71b std.os.speed_t: add type safety
and collect the missing flag bits from all the operating systems.
2024-02-12 21:49:09 -07:00
Andrew Kelley
a280ff2767 std.os.termios: add type safety to lflag field
This creates `tc_cflag_t` even though such a type is not defined by
libc.

I also collected the missing flag bits from all the operating systems.
2024-02-12 21:21:45 -07:00
Andrew Kelley
e97fa8b038 std.os.termios: add type safety to cflag field
This creates `tc_cflag_t` even though such a type is not defined by
libc.

I also collected the missing flag bits from all the operating systems.
2024-02-12 18:24:07 -07:00
Andrew Kelley
20abc0caee std.os.termios: add type safety to oflag field
This creates `tc_oflag_t` even though such a type is not defined by
libc.

I also collected the missing flag bits from all the operating systems.
2024-02-12 17:28:09 -07:00
Andrew Kelley
47643cc5cc std.os.termios: add type safety to iflag field
This creates `tc_iflag_t` even though such a type is not defined by
libc.

I also collected the missing flag bits from all the operating systems.
2024-02-12 16:43:51 -07: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
9bdf1ebe36 std.c.cc_t: consolidate same OS values 2024-02-12 15:44:28 -07:00
Andrew Kelley
5258c3caad std: add type safety to cc_t 2024-02-12 15:41:38 -07:00
Andrew Kelley
f995c1b08a std.c.O: fix illumos regression
introduced in c3eb592a34
2024-02-12 01:06:27 -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
09074d7cd7 std.os: proper use of inline
Uses `inline` only to forward the comptime-ness of the flags parameter
to function selection.

Also fixes doc comments in std.c.versionCheck.
2024-01-13 23:56:32 -07:00
Meghan Denny
f49a8c5431 std: make c.versionCheck() a comptime-known function 2024-01-12 16:17:39 -08:00
Veikka Tuominen
74010fecc7 translate-c: use Aro's tokenizer 2023-11-25 12:28:19 +02:00
Stephen Gregoratto
285970982a Add illumos OS tag
- Adds `illumos` to the `Target.Os.Tag` enum. A new function,
  `isSolarish` has been added that returns true if the tag is either
  Solaris or Illumos. This matches the naming convention found in Rust's
  `libc` crate[1].
- Add the tag wherever `.solaris` is being checked against.
- Check for the C pre-processor macro `__illumos__` in CMake to set the
  proper target tuple. Illumos distros patch their compilers to have
  this in the "built-in" set (verified with `echo | cc -dM -E -`).

  Alternatively you could check the output of `uname -o`.

Right now, both Solaris and Illumos import from `c/solaris.zig`. In the
future it may be worth putting the shared ABI bits in a base file, and
mixing that in with specific `c/solaris.zig`/`c/illumos.zig` files.

[1]: 6e02a329a2/src/unix/solarish
2023-10-02 15:31:49 -06:00
Stephen Gutekanst
55f0d8b41c std: correct getcontext for Android bionic libc
I have updated Felix's ZigAndroidTemplate to work with the latest
version of Zig and we are exploring adding Android support to Mach engine.

`std.c.getcontext` is _referenced_ but not _used_, and Android's bionic libc
does not implement `getcontext`. `std.os.linux.getcontext` also cannot be
used with bionic libc, so it seems prudent to just disable this extern for now.

This may not be the perfect long-term fix, but I have a golden rebuttal to that:
before I was unable to compile Zig applications for Android, and now I can.

<img width="828" alt="image" src="https://github.com/hexops/mach/assets/3173176/1e29142b-0419-4459-9c8b-75d92f87f822">

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2023-09-16 14:22:09 -07:00
Andrew Kelley
9f20d01cfb Revert "std.c: exposing timer api"
This reverts commit 54ea0bbcdd.
2023-07-31 10:51:44 -07:00
kcbanner
ccc9f82068 c: fixup getcontext
debug: supports_context -> have_ucontext, supports_getcontext -> have_getcontext
test: rework dwarf_unwind test case to also test the non-libc path
2023-07-20 22:58:14 -04:00
kcbanner
7bc1695f15 c: musl doesn't implement getcontext, so defer to our implementation in that case 2023-07-20 22:58:14 -04:00
kcbanner
23d9b59b86 c: add getcontext
debug: make getContext public
2023-07-20 22:58:14 -04: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
54ea0bbcdd std.c: exposing timer api 2023-06-18 08:09:42 -07:00
r00ster91
6e84f46990 std: replace builtin.Version with SemanticVersion 2023-06-17 13:17:34 -07:00
dweiller
3add9d8257 std.c: fix return type of recv/recvfrom on windows
Windows defines `recv` and `recvfrom` to return a value of type `int`,
rather than a pointer-sized signed integer, and so should use `c_int`
rather than `isize` for their return types.
2023-06-03 13:45:52 -07:00
Andrew Kelley
41a5ad28c9 std: child process API supports rusage data 2023-03-15 10:48:13 -07:00
Andrew Kelley
bb5006d728 std: add fchmodat
Also add `std.fs.has_executable_bit` for doing conditional compilation.

This adds the linux syscalls for chmod and fchmodat, as well as the
extern libc function declarations.

Only `fchmodat` is added to `std.os`, and it is not yet added to std.fs.
2023-03-03 02:37:45 -05:00
Philippe Pittoli
d09e39aefd Add std.c.umask. 2023-02-14 02:17:33 +02:00
Michael Dusan
599b3ef9e9 netbsd: use versioned __msync13 from libc
The system linker shows warning when `msync` is linked instead of `__msync13`:

  "warning: reference to compatibility msync(); include <sys/mman.h> for correct reference"

closes #14422
2023-01-28 19:05:38 -05:00
Jarred Sumner
a9eb463202 Make res nullable in getaddrinfo 2023-01-19 23:08:15 +02: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
775b0c1347 Revert "c.zig: Add definition for pthread_key_t"
This reverts commit aa3964477f.

This declaration is already provided by operating-system-specific files.
This is not the correct solution to the problem.

See #14013
Reopens #13950
2022-12-20 14:37:05 -07:00
Ganesan Rajagopal
aa3964477f c.zig: Add definition for pthread_key_t
Add missing definition for pthread_key_t

Closes #13950
2022-12-16 18:14:12 +02: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
Jonathan
81dadbcd77 pthread_sigmask 2022-11-13 17:36:56 +02:00
ominitay
295451dfe5
std: Replace use of stage1 function pointers 2022-09-29 21:45:30 +03:00
antlilja
ae8d26a6a0 Sema: add error for non-comptime param in comptime func
Adds error for taking a non comptime parameter in a function returning a
comptime-only type but not when that type is dependent on a parameter.

Co-authored-by: Veikka Tuominen <git@vexu.eu>
2022-08-27 11:17:48 +03:00
Sébastien Marie
397099b7ee pthread_key_create: make it build with stage2 2022-08-24 16:35:01 -04:00
aiotter
ad7f725dba std.c: Move Darwin-unspecific functions from std/c/darwin.zig to std/c.zig 2022-05-07 00:02:15 +09:00
aiotter
83d8378139 std.c: Add C APIs to read directories 2022-05-06 23:54:13 +09:00
Veikka Tuominen
101aac92c2 stage2: fix bugs preventing stage2 from building stage3 with LLVM 2022-04-15 23:32:26 +03:00
Locria Cyber
23bae382c9 Add sem_open & sem_close 2022-03-23 16:31:03 -04:00
Jakub Konka
76bceb240d std+macho: revert and fix exposing Mach wrappers in std.os and std.c 2022-03-13 17:03:04 +01:00
Jakub Konka
1af0c75d71 std: fix imports for darwin specific flags and funcs 2022-03-13 14:59:15 +01:00