<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/85275>85275</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [libc] implement ioctl
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            good first issue,
            libc
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          nickdesaulniers
      </td>
    </tr>
</table>

<pre>
    the ioctl syscall is pretty important, and is used by libc++ for LIBCXX_ENABLE_RANDOM_DEVICE support.

We currently define a few macros for ioctl in include/llvm-libc-macros/sys-ioctl-macros.h and generate ioctl.h via include/sys/ioctl.h.def.

I also see open coded calls to ioctl in:
- src/unistd/linux/isatty.cpp
- src/termios/linux/tcgetattr.cpp
- src/termios/linux/tcsendbreak.cpp
- src/termios/linux/tcgetsid.cpp
- src/termios/linux/tcdrain.cpp
- src/termios/linux/tcsetattr.cpp
- src/termios/linux/tcflush.cpp
- src/termios/linux/tcflow.cpp

I assume once ioctl is implemented, all of the above open coded calls should be replaced with the call to our internal wrapper.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUlM9vuzgQxf8acxkFEQea5MCh-SVV6nalPez2Vhl7CN4aG3nGzfLfryBpu5X2kO-FA_7M-DHzHorInj1iLaqdqA6ZStyFWHur3w2SSs5bjJQ1wYw1dwg2aHZAI2nlHFiCISLzCLYfQmTlWcg9KG-mo0RooBnB2UYLuRNyB22I8Py027--vh1fHnfPx7c_Hl8Ov__2djj--bQ_AqVh6pOL4iCKx-vzLwSdYkTPbgSDrfUIClq8QK90DDQ3veqyHqzXLhkU8uTcR7-Y7l5cOSFPNNJiJm-v8m7WekaPUfHt6_IOPqz6TyMap9rbWW6w_SHvCZSjAIQIYUAPOhg0MI2HgMOXMLG68QugqIU8JW-JzaTT-vTPdAEp5jHXw_ATZIy9neV_kqzPyIo53gcTetNEVO939yZr7mNNVNbfq-IXJLcuUXcvGi7f5NdOiFKPELz-9KylyaQOe_SMZrapcxBamGytmvDxP_ujLiRnoEGIODil0cDFcjeXzAHgACFFsJ4xeuXgEtUwYMwzU6_MdrVVGdbL9bIoVxtZlllXV7pUD5uqWT5sN1jpVbEpK61No1CaplUPma1lIctitSyX67IsyrySq23RalVU7bLarFtRFtgr6_LJ33mI58wSJaw3lVxXmVMNOprTLOU5BAOtjcQwM0JKIfdCymsi5RT4WM85adKZRFk4S0zfndmym38Nc0F1-J7gdahZiq7umAea7C1PQp7OlrvU5Dr0twh-JnGI4W_UPBudEk5LnCX_GwAA__88v394">