Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions pkgs/unix_api/constants.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
"<sys/mman.h>":
- MAP_ANONYMOUS
- MAP_FIXED
- MAP_PRIVATE
- MAP_SHARED
- MCL_CURRENT
- MCL_FUTURE
- MS_ASYNC
- MS_INVALIDATE
- MS_SYNC
- POSIX_MADV_DONTNEED
- POSIX_MADV_NORMAL
- POSIX_MADV_RANDOM
- POSIX_MADV_SEQUENTIAL
- POSIX_MADV_WILLNEED
- POSIX_TYPED_MEM_ALLOCATE
- POSIX_TYPED_MEM_ALLOCATE_CONTIG
- POSIX_TYPED_MEM_MAP_ALLOCATABLE
- PROT_EXEC
- PROT_NONE
- PROT_READ
- PROT_WRITE
"<sys/stat.h>":
- AT_SYMLINK_NOFOLLOW
- AT_RESOLVE_BENEATH
Expand Down Expand Up @@ -34,9 +56,11 @@
- UF_HIDDEN
"<errno.h>":
- EACCES
- EBADF
- EDOM
- EEXIST
- EINTR
- EINVAL
- EMFILE
- ENOENT
- ENOSPC
Expand Down
24 changes: 24 additions & 0 deletions pkgs/unix_api/functions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,30 @@
- prototype: "char *strerror(int)"
comment: "Formats an error code as a string."
url: "https://pubs.opengroup.org/onlinepubs/9699919799/functions/strerror.html"
"<sys/mman.h>":
- prototype: "int mlock(const void *, size_t)"
comment: Locks a range of process address space."
url: "https://pubs.opengroup.org/onlinepubs/9699919799/functions/mlock.html"
error_value: "-1"
- prototype: "int mlockall(int)"
comment: Locks the processes address space."
url: "https://pubs.opengroup.org/onlinepubs/9699919799/functions/mlockall.html"
- prototype: "void *mmap(void *, size_t, int, int, int, off_t)"
comment: Locks or unlocks the processes address space."

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Map pages of memory"

Should we take those comments from documentation / man pages?

url: "https://pubs.opengroup.org/onlinepubs/9699919799/functions/mmap.html"
error_value: "MAP_FAILED"
- prototype: "int mprotect(void *, size_t, int)"
comment: Sets the protection of mapped memory.
url: "https://pubs.opengroup.org/onlinepubs/9699919799/functions/mprotect.html"
error_value: "-1"
- prototype: "int munlock(const void *, size_t)"
comment: Unlocks a range of process address space."
url: "https://pubs.opengroup.org/onlinepubs/9699919799/functions/munlock.html"
error_value: "-1"
- prototype: "int munmap(void *, size_t)"
comment: Locks or unlocks the processes address space."

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Unmap pages of memory"

url: "https://pubs.opengroup.org/onlinepubs/9699919799/functions/munmap.html"
error_value: "-1"
"<sys/stat.h>":
- prototype: "int chmod(const char *, mode_t)"
comment: "Changes the mode of a file."
Expand Down
18 changes: 18 additions & 0 deletions pkgs/unix_api/handwritten-constants-ffigen.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Run with `dart run ffigen --config constants-ffigen.yaml`.
name: NativeAddBindings
description: |
Bindings for `handwritten_constants.h`.

Regenerate bindings with `dart run tool/generate.dart`.
output: 'lib/src/handwritten_constant_bindings.g.dart'
headers:
entry-points:
- 'src/handwritten_constants.h'

include-directives:
- 'src/handwritten_constants.h'
comments:
style: any
length: full
ffi-native:
asset-id: package:unix_api/libc_shim
7 changes: 6 additions & 1 deletion pkgs/unix_api/hook/build.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ void main(List<String> args) async {
libraries: [
if ([OS.linux].contains(input.config.code.targetOS)) 'crypt',
],
sources: ['src/libc_shim.c', 'src/constants.g.c', 'src/functions.g.c'],
sources: [
'src/libc_shim.c',
'src/constants.g.c',
'src/functions.g.c',
'src/handwritten_constants.c',
],
flags: ['-Weverything'],
).run(
input: input,
Expand Down
75 changes: 75 additions & 0 deletions pkgs/unix_api/lib/src/constant_bindings.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading