Skip to content

[libc] implement pipe2 #85289

@michaelrj-google

Description

@michaelrj-google

The pipe2 is defined on linux here: https://man7.org/linux/man-pages/man2/pipe.2.html

This is a simple syscall wrapper, so implementation should be straightforward.

Build System

In entrypoints.txt

  • Add the new function to the list of entrypoints for unistd.h (you need to do this before it will build)

In unistd/CMakeLists.txt

  • Add new entrypoint objects to the list
  • Also add it to the list for unistd/linux/CMakeLists.txt

In linux.td

  • Add the functions to the list of functions for unistd.h (this can be confusing, ask for help if you're stuck).

Code

Create unistd/pipe2.h

  • look at dup.h for an example of how this should be laid out (copying the whole file and modifying it is fine).

Create unistd/linux/pipe2.cpp

Testing

Create test/src/unistd/pipe2_test.cpp

  • This needs to test the function succeeding and failing
  • This is only testing the code you wrote, so don't worry too much about testing parts of the interface that the kernel handles.

Add your tests to test/src/unistd/CMakeLists.txt

  • Hopefully self-explanatory

Metadata

Metadata

Assignees

Labels

good first issuehttps://github.com/llvm/llvm-project/contributelibc

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions