mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-02-07 06:53:33 +00:00
This change ensures that if a file descriptor for an open disk file gets shared by multiple processes within a process tree, then lseek() changes will be visible across processes, and read() / write() are synchronized. Note this only applies to Windows, because UNIX kernels already do this.
50 lines
1 KiB
C
50 lines
1 KiB
C
#ifndef COSMOPOLITAN_LIBC_CALLS_STRUCT_FD_INTERNAL_H_
|
|
#define COSMOPOLITAN_LIBC_CALLS_STRUCT_FD_INTERNAL_H_
|
|
#include "libc/atomic.h"
|
|
#include "libc/thread/thread.h"
|
|
COSMOPOLITAN_C_START_
|
|
|
|
#define kFdEmpty 0
|
|
#define kFdFile 1
|
|
#define kFdSocket 2
|
|
#define kFdConsole 4
|
|
#define kFdSerial 5
|
|
#define kFdZip 6
|
|
#define kFdEpoll 7
|
|
#define kFdReserved 8
|
|
#define kFdDevNull 9
|
|
#define kFdDevRandom 10
|
|
|
|
struct Cursor {
|
|
pthread_mutex_t lock;
|
|
long pointer;
|
|
};
|
|
|
|
struct Fd {
|
|
char kind;
|
|
bool isdup;
|
|
bool isbound;
|
|
unsigned flags;
|
|
unsigned mode;
|
|
long handle;
|
|
int family;
|
|
int type;
|
|
int protocol;
|
|
unsigned rcvtimeo; /* millis; 0 means wait forever */
|
|
unsigned sndtimeo; /* millis; 0 means wait forever */
|
|
void *connect_op;
|
|
struct Cursor *shared;
|
|
};
|
|
|
|
struct Fds {
|
|
_Atomic(int) f; /* lowest free slot */
|
|
size_t n;
|
|
struct Fd *p, *e;
|
|
};
|
|
|
|
void __fd_lock(struct Fd *);
|
|
void __fd_unlock(struct Fd *);
|
|
struct Cursor *__cursor_new(void);
|
|
|
|
COSMOPOLITAN_C_END_
|
|
#endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_FD_INTERNAL_H_ */
|