Temporarily added partial posix libraris from Odin because posix support for Linux isn't done in Odin yet

This commit is contained in:
Zachary
2024-10-27 20:23:14 -07:00
parent dad9772659
commit 5400ef419a
4 changed files with 211 additions and 28 deletions

View File

@ -2,7 +2,8 @@ package libusb
import "core:c"
import "core:fmt"
import "core:sys/posix"
//TODO: Switch to sys/posix when linux support is finished
import "posix"
//TODO: Probably want to switch this to being statically linked
foreign import lib "system:usb-1.0"
@ -1076,7 +1077,7 @@ HOTPLUG_NO_FLAGS :: 0
* Wildcard matching for hotplug events */
HOTPLUG_MATCH_ANY :: -1
Hotplug_Callback :: #type proc "c" (
Hotplug_Callback_Fn :: #type proc "c" (
ctx: Context,
device: ^Device,
event: Hotplug_Event,
@ -1092,32 +1093,9 @@ Transfer_Type :: enum c.int {
STREAM = 4,
}
/** \ingroup libusb_asyncio
* Transfer status codes */
Transfer_Status :: enum c.int {
/** Transfer completed without error. Note that this does not indicate
* that the entire amount of requested data was transferred. */
COMPLETED,
/** Transfer failed */
ERROR,
/** Transfer timed out */
TIMED_OUT,
/** Transfer was cancelled */
CANCELLED,
/** For bulk/interrupt endpoints: halt condition detected (endpoint
* stalled). For control endpoints: control request not supported. */
STALL,
/** Device was disconnected */
NO_DEVICE,
/** Device sent more data than requested */
OVERFLOW,
/* NB! Remember to update libusb_error_name()
when adding new status codes here. */
}
Poll_Fd :: struct {
/** Numeric file descriptor */
fd: posix.FD,
fd: c.int,
/** Event flags to poll for from <poll.h>. POLLIN indicates that you
* should monitor this file descriptor for becoming ready to read from,
* and POLLOUT indicates that you should monitor this file descriptor for
@ -1125,9 +1103,9 @@ Poll_Fd :: struct {
events: posix.Poll_Event,
}
Poll_FD_Added_CB :: #type proc "c" (fd: posix.FD, events: posix.Poll_Event, user_date: rawptr)
Poll_FD_Added_CB :: #type proc "c" (fd: c.int, events: posix.Poll_Event, user_date: rawptr)
Poll_FD_Removed_CB :: #type proc "c" (fd: posix.FD, user_data: rawptr)
Poll_FD_Removed_CB :: #type proc "c" (fd: c.int, user_data: rawptr)
@(default_calling_convention = "c", link_prefix = "libusb_")
foreign lib {