From f3c700e0598b703b7930da5f45c120770d18cbb0 Mon Sep 17 00:00:00 2001 From: Thomas Willems Date: Fri, 20 Oct 2017 16:05:43 +0200 Subject: [PATCH] added support for SunOS --- README.md | 1 + src/whereami.c | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 671260a..3fd39b2 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,7 @@ Supported platforms: - Android - QNX Neutrino - FreeBSD +- SunOS Just drop `whereami.h` and `whereami.c` into your build and get started. (see also [customizing compilation]) diff --git a/src/whereami.c b/src/whereami.c index aa1c2d4..f51ea85 100644 --- a/src/whereami.c +++ b/src/whereami.c @@ -158,7 +158,7 @@ int WAI_PREFIX(getModulePath)(char* out, int capacity, int* dirname_length) return length; } -#elif defined(__linux__) || defined(__CYGWIN__) +#elif defined(__linux__) || defined(__CYGWIN__) || defined(__sun) #include #include @@ -170,8 +170,12 @@ int WAI_PREFIX(getModulePath)(char* out, int capacity, int* dirname_length) #include #if !defined(WAI_PROC_SELF_EXE) +#if defined(__sun) +#define WAI_PROC_SELF_EXE "/proc/self/path/a.out" +#else #define WAI_PROC_SELF_EXE "/proc/self/exe" #endif +#endif WAI_FUNCSPEC int WAI_PREFIX(getExecutablePath)(char* out, int capacity, int* dirname_length) @@ -217,8 +221,12 @@ int WAI_PREFIX(getExecutablePath)(char* out, int capacity, int* dirname_length) #endif #if !defined(WAI_PROC_SELF_MAPS) +#if defined(__sun) +#define WAI_PROC_SELF_MAPS "/proc/self/map" +#else #define WAI_PROC_SELF_MAPS "/proc/self/maps" #endif +#endif #if defined(__ANDROID__) || defined(ANDROID) #include