cosmopolitan/libc/calls/ioctl.h
Justine Tunney 8af197560e Improve Libc by making Python work even better
Actually Portable Python is now outperforming the Python binaries
that come bundled with Linux distros, at things like HTTP serving.
You can now have a fully featured Python install in just one .com
file that runs on six operating systems and is about 10mb in size.
With tuning, the tiniest is ~1mb. We've got most of the libraries
working, including pysqlite, and the repl now feels very pleasant.
The things you can't do quite yet are: threads and shared objects
but that can happen in the future, if the community falls in love
with this project and wants to see it developed further. Changes:

- Add siginterrupt()
- Add sqlite3 to Python
- Add issymlink() helper
- Make GetZipCdir() faster
- Add tgamma() and finite()
- Add legacy function lutimes()
- Add readlink() and realpath()
- Use heap allocations when appropriate
- Reorganize Python into two-stage build
- Save Lua / Python shell history to dotfile
- Integrate Python Lib embedding into linkage
- Make isregularfile() and isdirectory() go faster
- Make Python shell auto-completion work perfectly
- Make crash reports work better if changed directory
- Fix Python+NT open() / access() flag overflow error
- Disable Python tests relating to \N{LONG NAME} syntax
- Have Python REPL copyright() show all notice embeddings

The biggest technical challenge at the moment is working around
when Python tries to be too clever about filenames.
2021-08-18 22:16:23 -07:00

86 lines
4.6 KiB
C

#ifndef COSMOPOLITAN_LIBC_CALLS_IOCTL_H_
#define COSMOPOLITAN_LIBC_CALLS_IOCTL_H_
#include "libc/macros.internal.h"
#include "libc/sysv/consts/fio.h"
#include "libc/sysv/consts/sio.h"
#include "libc/sysv/consts/termios.h"
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
/*───────────────────────────────────────────────────────────────────────────│─╗
│ cosmopolitan § system calls » ioctl ─╬─│┼
╚────────────────────────────────────────────────────────────────────────────│*/
int ioctl(int, uint64_t, ...);
/*───────────────────────────────────────────────────────────────────────────│─╗
│ cosmopolitan § system calls » ioctl » undiamonding (size optimization) ─╬─│┼
╚────────────────────────────────────────────────────────────────────────────│*/
#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
#define ioctl(FD, REQUEST, ...) \
__IOCTL_DISPATCH(__EQUIVALENT, ioctl_default(FD, REQUEST, ##__VA_ARGS__), \
FD, REQUEST, ##__VA_ARGS__)
#define __EQUIVALENT(X, Y) (__builtin_constant_p((X) == (Y)) && ((X) == (Y)))
#define __IOCTL_DISPATCH(CMP, DEFAULT, FD, REQUEST, ...) \
({ \
int ReZ; \
if (CMP(REQUEST, TIOCGWINSZ)) { \
ReZ = ioctl_tiocgwinsz(FD, __VA_ARGS__); \
} else if (CMP(REQUEST, TIOCSWINSZ)) { \
ReZ = ioctl_tiocswinsz(FD, __VA_ARGS__); \
} else if (CMP(REQUEST, TCGETS)) { \
ReZ = ioctl_tcgets(FD, __VA_ARGS__); \
} else if (CMP(REQUEST, TCSETS)) { \
ReZ = ioctl_tcsets(FD, REQUEST, __VA_ARGS__); \
} else if (CMP(REQUEST, TCSETSW)) { \
ReZ = ioctl_tcsets(FD, REQUEST, __VA_ARGS__); \
} else if (CMP(REQUEST, TCSETSF)) { \
ReZ = ioctl_tcsets(FD, REQUEST, __VA_ARGS__); \
} else if (CMP(REQUEST, SIOCGIFCONF)) { \
ReZ = ioctl_siocgifconf(FD, __VA_ARGS__); \
} else if (CMP(REQUEST, SIOCGIFADDR)) { \
ReZ = ioctl_siocgifaddr(FD, __VA_ARGS__); \
} else if (CMP(REQUEST, SIOCGIFNETMASK)) { \
ReZ = ioctl_siocgifnetmask(FD, __VA_ARGS__); \
} else if (CMP(REQUEST, SIOCGIFBRDADDR)) { \
ReZ = ioctl_siocgifbrdaddr(FD, __VA_ARGS__); \
} else if (CMP(REQUEST, SIOCGIFDSTADDR)) { \
ReZ = ioctl_siocgifdstaddr(FD, __VA_ARGS__); \
} else if (CMP(REQUEST, SIOCGIFFLAGS)) { \
ReZ = ioctl_siocgifflags(FD, __VA_ARGS__); \
} else if (CMP(REQUEST, FIONBIO)) { \
ReZ = ioctl_default(FD, REQUEST, __VA_ARGS__); \
} else if (CMP(REQUEST, FIOCLEX)) { \
ReZ = ioctl_fioclex(FD, REQUEST); \
} else if (CMP(REQUEST, FIONCLEX)) { \
ReZ = ioctl_fioclex(FD, REQUEST); \
} else { \
ReZ = DEFAULT; \
} \
ReZ; \
})
int ioctl_tcgets(int, void *);
int ioctl_tcgets_nt(int, void *);
int ioctl_tcsets(int, uint64_t, void *);
int ioctl_tcsets_nt(int, uint64_t, void *);
int ioctl_tiocgwinsz(int, void *);
int ioctl_tiocgwinsz_nt(int, void *);
int ioctl_tiocswinsz(int, void *);
int ioctl_tiocswinsz_nt(int, void *);
int ioctl_siocgifconf(int, void *);
int ioctl_siocgifaddr(int, void *);
int ioctl_siocgifdstaddr(int, void *);
int ioctl_siocgifnetmask(int, void *);
int ioctl_siocgifbrdaddr(int, void *);
int ioctl_siocgifflags(int, void *);
int ioctl_default(int, uint64_t, void *);
int ioctl_fioclex(int, int);
#endif /* GNUC && !ANSI */
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_LIBC_CALLS_IOCTL_H_ */