Created
May 30, 2018 23:28
-
-
Save NattyNarwhal/e18ca03da90a67504e96b59b998aaf70 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/Native/Unix/System.Native/pal_errno.c b/src/Native/Unix/System.Native/pal_errno.c | |
index 3a7972369..4cff18a 100644 | |
--- a/src/Native/Unix/System.Native/pal_errno.c | |
+++ b/src/Native/Unix/System.Native/pal_errno.c | |
@@ -130,8 +130,10 @@ int32_t SystemNative_ConvertErrorPlatformToPal(int32_t platformErrno) | |
return Error_ENOTCONN; | |
case ENOTDIR: | |
return Error_ENOTDIR; | |
+#if !defined(_AIX) | |
case ENOTEMPTY: | |
return Error_ENOTEMPTY; | |
+#endif | |
#ifdef ENOTRECOVERABLE // not available in NetBSD | |
case ENOTRECOVERABLE: | |
return Error_ENOTRECOVERABLE; | |
diff --git a/src/Native/Unix/System.Native/pal_io.c b/src/Native/Unix/System.Native/pal_io.c | |
index 320dccd..ef5911a 100644 | |
--- a/src/Native/Unix/System.Native/pal_io.c | |
+++ b/src/Native/Unix/System.Native/pal_io.c | |
@@ -2,6 +2,11 @@ | |
// The .NET Foundation licenses this file to you under the MIT license. | |
// See the LICENSE file in the project root for more information. | |
+#ifdef _AIX | |
+// For getline (declare this before stdio) | |
+#define _GETDELIM 1 | |
+#endif | |
+ | |
#include "pal_compiler.h" | |
#include "pal_config.h" | |
#include "pal_errno.h" | |
@@ -37,6 +42,13 @@ | |
#include <sys/inotify.h> | |
#endif | |
+#if defined(_AIX) | |
+#include <alloca.h> | |
+// Somehow, AIX mangles the definition for this behind a C++ def | |
+// Redeclare it here | |
+extern int getpeereid(int, uid_t *__restrict__, gid_t *__restrict__); | |
+#endif | |
+ | |
#if HAVE_STAT64 | |
#define stat_ stat64 | |
#define fstat_ fstat64 | |
@@ -78,6 +90,7 @@ c_static_assert(PAL_S_IFSOCK == S_IFSOCK); | |
// Validate that our enum for inode types is the same as what is | |
// declared by the dirent.h header on the local system. | |
+#if !defined(_AIX) | |
c_static_assert(PAL_DT_UNKNOWN == DT_UNKNOWN); | |
c_static_assert(PAL_DT_FIFO == DT_FIFO); | |
c_static_assert(PAL_DT_CHR == DT_CHR); | |
@@ -87,6 +100,7 @@ c_static_assert(PAL_DT_REG == DT_REG); | |
c_static_assert(PAL_DT_LNK == DT_LNK); | |
c_static_assert(PAL_DT_SOCK == DT_SOCK); | |
c_static_assert(PAL_DT_WHT == DT_WHT); | |
+#endif | |
// Validate that our Lock enum value are correct for the platform | |
c_static_assert(PAL_LOCK_SH == LOCK_SH); | |
@@ -325,7 +339,30 @@ static void ConvertDirent(const struct dirent* entry, struct DirectoryEntry* out | |
// the start of the unmanaged string. Give the caller back a pointer to the | |
// location of the start of the string that exists in their own byte buffer. | |
outputEntry->Name = entry->d_name; | |
+#if defined(_AIX) | |
+ /* AIX has no d_type, make a substitute */ | |
+ struct stat s; | |
+ stat(entry->d_name, &s); | |
+ if (S_ISDIR(s.st_mode)) { | |
+ outputEntry->InodeType = PAL_DT_DIR; | |
+ } else if (S_ISFIFO(s.st_mode)) { | |
+ outputEntry->InodeType = PAL_DT_FIFO; | |
+ } else if (S_ISCHR(s.st_mode)) { | |
+ outputEntry->InodeType = PAL_DT_CHR; | |
+ } else if (S_ISBLK(s.st_mode)) { | |
+ outputEntry->InodeType = PAL_DT_BLK; | |
+ } else if (S_ISREG(s.st_mode)) { | |
+ outputEntry->InodeType = PAL_DT_REG; | |
+ } else if (S_ISLNK(s.st_mode)) { | |
+ outputEntry->InodeType = PAL_DT_LNK; | |
+ } else if (S_ISSOCK(s.st_mode)) { | |
+ outputEntry->InodeType = PAL_DT_SOCK; | |
+ } else { | |
+ outputEntry->InodeType = PAL_DT_UNKNOWN; | |
+ } | |
+#else | |
outputEntry->InodeType = (int32_t)entry->d_type; | |
+#endif | |
#if HAVE_DIRENT_NAME_LEN | |
outputEntry->NameLength = entry->d_namlen; | |
diff --git a/src/Native/Unix/System.Native/pal_io.h b/src/Native/Unix/System.Native/pal_io.h | |
index 9f80c8b..f8e5198 100644 | |
--- a/src/Native/Unix/System.Native/pal_io.h | |
+++ b/src/Native/Unix/System.Native/pal_io.h | |
@@ -267,12 +267,22 @@ enum SysConfName | |
*/ | |
enum PollEvents | |
{ | |
+#if defined(_AIX) | |
+/* of course AIX is different */ | |
+ PAL_POLLIN = 0x0001, /* non-urgent readable data available */ | |
+ PAL_POLLPRI = 0x0004, /* urgent readable data available */ | |
+ PAL_POLLOUT = 0x0002, /* data can be written without blocked */ | |
+ PAL_POLLERR = 0x4000, /* an error occurred */ | |
+ PAL_POLLHUP = 0x2000, /* the file descriptor hung up */ | |
+ PAL_POLLNVAL = 0x8000, /* the requested events were invalid */ | |
+#else | |
PAL_POLLIN = 0x0001, /* non-urgent readable data available */ | |
PAL_POLLPRI = 0x0002, /* urgent readable data available */ | |
PAL_POLLOUT = 0x0004, /* data can be written without blocked */ | |
PAL_POLLERR = 0x0008, /* an error occurred */ | |
PAL_POLLHUP = 0x0010, /* the file descriptor hung up */ | |
PAL_POLLNVAL = 0x0020, /* the requested events were invalid */ | |
+#endif | |
}; | |
/** |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment