-
-
Notifications
You must be signed in to change notification settings - Fork 831
Create unistd.h #1836
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create unistd.h #1836
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| // Source - https://stackoverflow.com/a | ||
| // Posted by AShelly, modified by community. See post 'Timeline' for change history | ||
| // Retrieved 2025-12-21, License - CC BY-SA 4.0 | ||
|
|
||
| #ifndef _UNISTD_H | ||
| #define _UNISTD_H 1 | ||
|
|
||
| /* This is intended as a drop-in replacement for unistd.h on Windows. | ||
| * Please add functionality as needed. | ||
| * https://stackoverflow.com/a/826027/1202830 | ||
| */ | ||
|
|
||
| #include <stdlib.h> | ||
| #include <io.h> | ||
| #include <getopt.h> /* getopt at: https://gist.github.com/ashelly/7776712 */ | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| #include <process.h> /* for getpid() and the exec..() family */ | ||
| #include <direct.h> /* for _getcwd() and _chdir() */ | ||
|
|
||
| #define srandom srand | ||
| #define random rand | ||
|
|
||
| /* Values for the second argument to access. | ||
| These may be OR'd together. */ | ||
| #define R_OK 4 /* Test for read permission. */ | ||
| #define W_OK 2 /* Test for write permission. */ | ||
| //#define X_OK 1 /* execute permission - unsupported in windows*/ | ||
| #define F_OK 0 /* Test for existence. */ | ||
|
|
||
| #define access _access | ||
| #define dup2 _dup2 | ||
| #define execve _execve | ||
| #define ftruncate _chsize | ||
| #define unlink _unlink | ||
| #define fileno _fileno | ||
| #define getcwd _getcwd | ||
| #define chdir _chdir | ||
| #define isatty _isatty | ||
| #define lseek _lseek | ||
| /* read, write, and close are NOT being #defined here, because while there are file handle specific versions for Windows, they probably don't work for sockets. You need to look at your app and consider whether to call e.g. closesocket(). */ | ||
|
|
||
| #ifdef _WIN64 | ||
| #define ssize_t __int64 | ||
| #else | ||
| #define ssize_t long | ||
| #endif | ||
|
|
||
| #define STDIN_FILENO 0 | ||
| #define STDOUT_FILENO 1 | ||
| #define STDERR_FILENO 2 | ||
| /* should be in some equivalent to <sys/types.h> */ | ||
| //typedef __int8 int8_t; | ||
| typedef __int16 int16_t; | ||
| typedef __int32 int32_t; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These |
||
| typedef __int64 int64_t; | ||
| typedef unsigned __int8 uint8_t; | ||
| typedef unsigned __int16 uint16_t; | ||
| typedef unsigned __int32 uint32_t; | ||
| typedef unsigned __int64 uint64_t; | ||
|
|
||
| #endif /* unistd.h */ | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
License incompatibility: CC BY-SA 4.0 is a copyleft license that is incompatible with MIT. Stack Overflow content cannot be copied verbatim into an MIT-licensed project. This file must either be removed, rewritten from scratch under MIT, or replaced with
#ifdef _WIN32guards inops_hip.cuh(as done in PR #1846 and #1843).