Return-Path: Delivered-To: apmail-harmony-commits-archive@www.apache.org Received: (qmail 67829 invoked from network); 3 Aug 2010 07:37:01 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 3 Aug 2010 07:37:01 -0000 Received: (qmail 47741 invoked by uid 500); 3 Aug 2010 07:37:01 -0000 Delivered-To: apmail-harmony-commits-archive@harmony.apache.org Received: (qmail 47648 invoked by uid 500); 3 Aug 2010 07:36:58 -0000 Mailing-List: contact commits-help@harmony.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@harmony.apache.org Delivered-To: mailing list commits@harmony.apache.org Received: (qmail 47636 invoked by uid 99); 3 Aug 2010 07:36:58 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 03 Aug 2010 07:36:58 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 03 Aug 2010 07:36:57 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id D348523889B3; Tue, 3 Aug 2010 07:35:40 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r981763 - /harmony/enhanced/java/trunk/jdktools/modules/samsa/src/main/native/samsa/samsa.c Date: Tue, 03 Aug 2010 07:35:40 -0000 To: commits@harmony.apache.org From: hindessm@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100803073540.D348523889B3@eris.apache.org> Author: hindessm Date: Tue Aug 3 07:35:40 2010 New Revision: 981763 URL: http://svn.apache.org/viewvc?rev=981763&view=rev Log: Revert all but the basename fix from commit r951009: These implementations should be portable enough that we don't need the #error. This will break on aix & z/OS until we add platform-specific implementation for them. Modified: harmony/enhanced/java/trunk/jdktools/modules/samsa/src/main/native/samsa/samsa.c Modified: harmony/enhanced/java/trunk/jdktools/modules/samsa/src/main/native/samsa/samsa.c URL: http://svn.apache.org/viewvc/harmony/enhanced/java/trunk/jdktools/modules/samsa/src/main/native/samsa/samsa.c?rev=981763&r1=981762&r2=981763&view=diff ============================================================================== --- harmony/enhanced/java/trunk/jdktools/modules/samsa/src/main/native/samsa/samsa.c (original) +++ harmony/enhanced/java/trunk/jdktools/modules/samsa/src/main/native/samsa/samsa.c Tue Aug 3 07:35:40 2010 @@ -15,10 +15,6 @@ * limitations under the License. */ -#if defined(FREEBSD) -#include -#endif - #include #include #include @@ -95,8 +91,8 @@ typedef struct ToolData { } TOOLDATA; char *cleanToolName(const char *); -char *getExeDir(const char*); -char *getRoot(const char*); +char *getExeDir(); +char *getRoot(); TOOLDATA *getToolData(const char *, const char *, int toolType); int getToolType(const char*, const char*); char* jarFile(const char*, const char*); @@ -145,7 +141,7 @@ int main (int argc, char **argv, char ** * and the full paths to jars. This way, we can be called * from anywhere */ - root = getRoot(argv[0]); + root = getRoot(); // printf("root = %s\n", root); @@ -437,14 +433,14 @@ char *cleanToolName(const char *name) } /****************************************************************** - * getRoot(const char* argv0) + * getRoot() * * returns the root (JDK or JRE) where this executable is located * if it can figure it out or NULL if it can't */ -char *getRoot(const char* argv0) { +char *getRoot() { - char *exeDir = getExeDir(argv0); + char *exeDir = getExeDir(); char *last = strrchr(exeDir, PATH_SEPARATOR_CHAR); @@ -457,27 +453,36 @@ char *getRoot(const char* argv0) { } /***************************************************************** - * getExeDir(const char* argv0) + * getExeDir() * * returns directory of running exe */ -char *getExeDir(const char* argv0) { +char *getExeDir() { char *last = NULL; -#if defined(WIN32) +#if defined(LINUX) + char buffer[PATH_MAX + 1]; + + int size = readlink ("/proc/self/exe", buffer, sizeof(buffer)-2); + + buffer[size+1] = '\0'; +#elif defined(FREEBSD) + Dl_info info; + char buffer[PATH_MAX + 1]; + if (dladdr( (const void*)&main, &info) == 0) { + return NULL; + } + strncpy(buffer, info.dli_fname, PATH_MAX); + buffer[PATH_MAX] = '\0'; + +#elif defined(WIN32) char buffer[512]; DWORD dwRet = GetModuleFileName(NULL, buffer, 512); // FIXME - handle this right - it could be that 512 isn't enough #else - char buffer[PATH_MAX + 1]; - - char *rc = realpath(argv0, buffer); - if (!rc) { - return NULL; - } - buffer[PATH_MAX] = '\0'; +#error Need to implement executable name code #endif last = strrchr(buffer, PATH_SEPARATOR_CHAR);