Index: depends/build/defines.mk =================================================================== --- depends/build/defines.mk (revision 514702) +++ depends/build/defines.mk (working copy) @@ -60,8 +60,14 @@ OPT += $(HYDEBUGCFLAGS) endif -MDLLIBFILES = $(DLLPATH)libhythr.so $(LIBPATH)libhycommon.a +MDLLIBFILES = $(LIBPATH)libhycommon.a +ifeq ($(HY_NO_THR),false) +MDLLIBFILES += $(DLLPATH)libhythr.so +else +DEFINES += -DHY_NO_THR +endif + ifeq ($(HY_NO_SIG),false) MDLLIBFILES += $(DLLPATH)libhysig.so else Index: depends/build/defines.mak =================================================================== --- depends/build/defines.mak (revision 514702) +++ depends/build/defines.mak (working copy) @@ -57,10 +57,16 @@ HYCFLAGS = $(HYRELEASECFLAGS) $(HYCOMMONCFLAGS) !ENDIF -MDLLIBFILES = $(LIBPATH)hythr.lib $(LIBPATH)hycommon.lib +MDLLIBFILES = $(LIBPATH)hycommon.lib +!IF "$(HY_NO_THR)" == "false" +MDLLIBFILES = $(MDLLIBFILES) $(LIBPATH)hythr.lib +!ELSE +HYCFLAGS = $(HYCFLAGS) -DHY_NO_THR +!ENDIF + !IF "$(HY_NO_SIG)" == "false" MDLLIBFILES = $(MDLLIBFILES) $(LIBPATH)hysig.lib -!ELSE +!ELSE HYCFLAGS = $(HYCFLAGS) -DHY_NO_SIG !ENDIF Index: modules/archive/src/main/native/zip/shared/zipsup.c =================================================================== --- modules/archive/src/main/native/zip/shared/zipsup.c (revision 514702) +++ modules/archive/src/main/native/zip/shared/zipsup.c (working copy) @@ -1115,7 +1115,9 @@ zip_closeZipFile (HyPortLibrary * portLib, struct HyZipFile * zipFile) { PORT_ACCESS_FROM_PORT (portLib); - +#if defined(HY_NO_THR) + THREAD_ACCESS_FROM_PORT(portLib); +#endif /* HY_NO_THR */ IDATA fd; ENTER (); @@ -1325,6 +1327,9 @@ HyZipEntry * zipEntry, IDATA * nextEntryPointer) { PORT_ACCESS_FROM_PORT (portLib); +#if defined(HY_NO_THR) + THREAD_ACCESS_FROM_PORT(portLib); +#endif /* HY_NO_THR */ IDATA result; BOOLEAN retryAllowed = TRUE; IDATA pointer; @@ -1447,6 +1452,9 @@ BOOLEAN findDirectory) { PORT_ACCESS_FROM_PORT (portLib); +#if defined(HY_NO_THR) + THREAD_ACCESS_FROM_PORT(portLib); +#endif /* HY_NO_THR */ IDATA result, position; BOOLEAN retryAllowed = TRUE; I_64 seekResult; @@ -1584,6 +1592,9 @@ HyZipEntry * entry, U_8 * buffer, U_32 bufferSize) { PORT_ACCESS_FROM_PORT (portLib); +#if defined(HY_NO_THR) + THREAD_ACCESS_FROM_PORT(portLib); +#endif /* HY_NO_THR */ I_32 result; U_8 *dataBuffer; @@ -1754,6 +1765,9 @@ HyZipEntry * entry, U_8 * buffer, U_32 bufferSize) { PORT_ACCESS_FROM_PORT (portLib); +#if defined(HY_NO_THR) + THREAD_ACCESS_FROM_PORT(portLib); +#endif /* HY_NO_THR */ I_32 result; U_8 *extraFieldBuffer; @@ -1862,6 +1876,9 @@ HyZipEntry * entry, U_8 * buffer, U_32 bufferSize) { PORT_ACCESS_FROM_PORT (portLib); +#if defined(HY_NO_THR) + THREAD_ACCESS_FROM_PORT(portLib); +#endif /* HY_NO_THR */ I_32 result; U_8 *fileCommentBuffer; @@ -1973,6 +1990,9 @@ HyZipCachePool * cachePool) { PORT_ACCESS_FROM_PORT (portLib); +#if defined(HY_NO_THR) + THREAD_ACCESS_FROM_PORT(portLib); +#endif /* HY_NO_THR */ IDATA fd = -1; I_32 result = 0; @@ -2149,6 +2169,9 @@ HyZipEntry * entry, IDATA offset) { PORT_ACCESS_FROM_PORT (portLib); +#if defined(HY_NO_THR) + THREAD_ACCESS_FROM_PORT(portLib); +#endif /* HY_NO_THR */ I_32 result; I_64 seekResult; Index: modules/luni/src/main/native/launcher/unix/main_hlp.c =================================================================== --- modules/luni/src/main/native/launcher/unix/main_hlp.c (revision 0) +++ modules/luni/src/main/native/launcher/unix/main_hlp.c (revision 0) @@ -0,0 +1,407 @@ +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#if defined(LINUX) +#include +#endif +#if defined(FREEBSD) +#include +#include +#endif + +#include + +#include +#include +#include +#include + + +#include "main_hlp.h" + + +static BOOLEAN isSymbolicLink (char *filename); +static IDATA cwdname (char **result); +static IDATA readSymbolicLink (char *linkFilename, char **result); +static IDATA searchSystemPath (char *filename, char **result); + + +int +main_get_executable_name (char *argv0, char **result) +{ + +#if defined(LINUX) + return readSymbolicLink ("/proc/self/exe", result); +#else + IDATA retval = -1; + IDATA length; + char *p; + char *currentName = NULL; + char *currentPath = NULL; + char *originalWorkingDirectory = NULL; + + if (!argv0) + { + return -1; + } + currentPath = main_mem_allocate_memory(strlen (argv0) + 1); + if (currentPath) + { + strcpy(currentPath, argv0); + } + if (!currentPath) + { + retval = -1; + goto cleanup; + } + retval = cwdname(&originalWorkingDirectory); + if (retval) + { + retval = -1; + goto cleanup; + } +gotPathName: + /* split path into directory part and filename part. */ + p = strrchr (currentPath, '/'); + if (p) + { + *p++ = '\0'; + currentName = main_mem_allocate_memory(strlen (p) + 1); + if (!currentName) + { + retval = -1; + goto cleanup; + } + strcpy (currentName, p); + } + else + { + currentName = currentPath; + currentPath = NULL; + retval = searchSystemPath (currentName, ¤tPath); + if (retval) + { + retval = -1; + goto cleanup; + } + } + /* go there */ + if (currentPath) + { + if (currentPath[0]) + { + if (0 != chdir (currentPath)) + { + retval = -1; + goto cleanup; + } + } + main_mem_free_memory(currentPath); + currentPath = NULL; + } + if (isSymbolicLink (currentName)) + { + /* try to follow the link. */ + retval = readSymbolicLink (currentName, ¤tPath); + if (retval) + { + retval = -1; + goto cleanup; + } + main_mem_free_memory(currentName); + currentName = NULL; + goto gotPathName; + } + retval = cwdname (¤tPath); + if (retval) + { + retval = -1; + goto cleanup; + } + /* Put name and path back together */ + *result = main_mem_allocate_memory(strlen(currentPath) + strlen(currentName) + 2); + if (!*result) + { + retval = -1; + goto cleanup; + } + strcpy (*result, currentPath); + if (currentPath[0] && (currentPath[strlen (currentPath) - 1] != '/')) + { + strcat (*result, "/"); + } + strcat (*result, currentName); + /* Finished. */ + retval = 0; +cleanup: + if (originalWorkingDirectory) + { + chdir (originalWorkingDirectory); + main_mem_free_memory(originalWorkingDirectory); + originalWorkingDirectory = NULL; + } + if (currentPath) + { + main_mem_free_memory(currentPath); + currentPath = NULL; + } + if (currentName) + { + main_mem_free_memory(currentName); + currentName = NULL; + } + return retval; +#endif +} + +void * +main_mem_allocate_memory (int byteAmount) +{ + void *pointer = NULL; + void *mem; + if (byteAmount == 0) + { /* prevent malloc from failing causing allocate to return null */ + byteAmount = 1; + } + pointer = malloc(byteAmount); + return pointer; +} + +void +main_mem_free_memory (void *memoryPointer) +{ + free (memoryPointer); +} + + +/** + * @internal Examines the named file to determine if it is a symbolic link. On platforms which don't have + * symbolic links (or where we can't tell) or if an unexpected error occurs, just answer FALSE. + */ +static BOOLEAN +isSymbolicLink (char *filename) +{ + struct stat statbuf; + if (!lstat (filename, &statbuf)) + { + if (S_ISLNK (statbuf.st_mode)) + { + return TRUE; + } + } + return FALSE; +} + +/** + * @internal Returns the current working directory. + * + * @return 0 on success, -1 on failure. + * + * @note The buffer to hold this string (including its terminating NUL) is allocated with + * main_mem_allocate_memory. The caller should free this memory with + * main_mem_free_memory when it is no longer needed. + */ +static IDATA +cwdname (char **result) +{ + char *cwd; + int allocSize = 256; + +doAlloc: + cwd = main_mem_allocate_memory(allocSize); + if (!cwd) + { + return -1; + } + if (!getcwd (cwd, allocSize - 1)) + { + main_mem_free_memory(cwd); + if (errno == ERANGE) + { + allocSize += 256; + goto doAlloc; + } + return -1; + } + *result = cwd; + return 0; +} + + +/** + * @internal Attempts to read the contents of a symbolic link. (The contents are the relative pathname of + * the thing linked to). A buffer large enough to hold the result (and the terminating NUL) is + * allocated with main_mem_allocate_memory. The caller should free this buffer with + * main_mem_free_memory when it is no longer needed. + * On success, returns 0. On error, returns -1. + */ +static IDATA +readSymbolicLink (char *linkFilename, + char **result) +{ + /* TODO: remove this ifdef and find out what other builds break (if any) */ +#if defined(LINUX) + char fixedBuffer[PATH_MAX + 1]; + int size = readlink (linkFilename, fixedBuffer, sizeof (fixedBuffer) - 1); + if (size <= 0) + { + return -1; + } + fixedBuffer[size++] = '\0'; + *result = main_mem_allocate_memory(size); + if (!*result) + { + return -1; + } + strcpy (*result, fixedBuffer); + return 0; +#else + return -1; +#endif +} + + +/** + * @internal Searches through the system PATH for the named file. If found, it returns the path entry + * which matched the file. A buffer large enough to hold the proper path entry (without a + * trailing slash, but with the terminating NUL) is allocated with main_mem_allocate_memory. + * The caller should free this buffer with main_mem_free_memory when it is no longer + * needed. On success, returns 0. On error (including if the file is not found), -1 is returned. + */ +static IDATA +searchSystemPath (char *filename, char **result) +{ + char *pathCurrent; + char *pathNext; + int length; + DIR *sdir = NULL; + struct dirent *dirEntry; + /* This should be sufficient for a single entry in the PATH var, though the var itself */ + /* could be considerably longer.. */ + char temp[PATH_MAX + 1]; + + if (!(pathNext = getenv ("PATH"))) + { + return -1; + } + + while (pathNext) + { + pathCurrent = pathNext; + pathNext = strchr (pathCurrent, ':'); + if (pathNext) + { + length = (pathNext - pathCurrent); + pathNext += 1; + } + else + { + length = strlen (pathCurrent); + } + if (length > PATH_MAX) + { + length = PATH_MAX; + } + memcpy (temp, pathCurrent, length); + temp[length] = '\0'; + + if (!length) + { /* empty path entry */ + continue; + } + if (sdir = opendir (temp)) + { + while (dirEntry = readdir (sdir)) + { + if (!strcmp (dirEntry->d_name, filename)) + { + closedir (sdir); + /* found! */ + *result = main_mem_allocate_memory(strlen (temp) + 1); + if (!result) + { + return -1; + } + strcpy (*result, temp); + return 0; + } + } + closedir (sdir); + } + } + /* not found */ + return -1; +} + +/** + * Close a shared library. + * + * @param[in] descriptor Shared library handle to close. + * + * @return 0 on success, any other value on failure. + */ +int VMCALL +main_close_port_library (UDATA descriptor) +{ + return (UDATA) dlclose ((void *)descriptor); +} + +/** + * Opens a shared library . + * + * @param[out] descriptor Pointer to memory which is filled in with shared-library handle on success. + * + * @return 0 on success, any other value on failure. + * + * @note contents of descriptor are undefined on failure. + */ +#include +int VMCALL +main_open_port_library (UDATA * descriptor) +{ + void *handle; + char *openName = "libhyprt.so"; + + handle = dlopen (openName, RTLD_NOW); + if (handle == NULL) + { +puts(dlerror()); + return -1; + } + + *descriptor = (UDATA) handle; + return 0; +} + + +/** + * Search for a function named 'name' taking argCount in the shared library 'descriptor'. + * + * @param[in] descriptor Shared library to search. + * @param[in] name Function to look up. + * @param[out] func Pointer to the function. + * + * @return 0 on success, any other value on failure. + * + * @note contents of func are undefined on failure. + */ +UDATA VMCALL +main_lookup_name (UDATA descriptor, char *name, UDATA * func) +{ + void *address; + address = dlsym ((void *)descriptor, name); + if (address == NULL) + { + return 1; + } + *func = (UDATA) address; + return 0; +} Property changes on: modules/luni/src/main/native/launcher/unix/main_hlp.c ___________________________________________________________________ Name: svn:eol-style + native Index: modules/luni/src/main/native/launcher/unix/makefile =================================================================== --- modules/luni/src/main/native/launcher/unix/makefile (revision 514702) +++ modules/luni/src/main/native/launcher/unix/makefile (working copy) @@ -21,8 +21,12 @@ BUILDFILES = $(SHAREDSUB)main.o $(SHAREDSUB)cmain.o \ $(SHAREDSUB)launcher_copyright.o $(SHAREDSUB)strbuf.o \ - $(SHAREDSUB)libhlp.o + $(SHAREDSUB)libhlp.o +ifeq ($(HY_NO_THR),false) MDLLIBFILES += $(DLLPATH)libhyprt.so +else +BUILDFILES += main_hlp.o +endif EXENAME = $(EXEPATH)java include $(HY_HDK)/build/make/rules.mk Index: modules/luni/src/main/native/launcher/shared/main.c =================================================================== --- modules/luni/src/main/native/launcher/shared/main.c (revision 514702) +++ modules/luni/src/main/native/launcher/shared/main.c (working copy) @@ -24,6 +24,9 @@ #include "hyexelibnls.h" /* nls strings */ #include "libhlp.h" /* defaults and environment variables and string buffer functions */ #include "strhelp.h" /* for properties file parsing */ +#ifdef HY_NO_THR +#include "main_hlp.h" /* plaftorm specific launcher helpers */ +#endif /* HY_NO_THR */ #include #include @@ -63,7 +66,11 @@ char *VMCALL vmdll_parseCmdLine PROTOTYPE ((HyPortLibrary * portLibrary, UDATA lastLegalArg, char **argv)); char *VMCALL vmdlldir_parseCmdLine +#ifndef HY_NO_THR PROTOTYPE ((HyPortLibrary * portLibrary, UDATA lastLegalArg, char **argv)); +#else /* HY_NO_THR */ +PROTOTYPE ((UDATA lastLegalArg, char **argv)); +#endif /* HY_NO_THR */ UDATA VMCALL gpProtectedMain PROTOTYPE ((struct haCmdlineOptions * args)); IDATA convertString PROTOTYPE ((JNIEnv * env, HyPortLibrary * portLibrary, jclass stringClass, @@ -73,7 +80,11 @@ int augmentToolsArgs PROTOTYPE ((HyPortLibrary * portLibrary, int *argc, char ***argv)); static IDATA addDirsToPath +#ifndef HY_NO_THR PROTOTYPE ((HyPortLibrary * portLibrary, int count, char *newPathToAdd[], char **argv)); +#else /* HY_NO_THR */ +PROTOTYPE ((int count, char *newPathToAdd[], char **argv)); +#endif /* HY_NO_THR */ int main_runJavaMain PROTOTYPE ((JNIEnv * env, char *mainClassName, int nameIsUTF, int java_argc, char **java_argv, HyPortLibrary * portLibrary)); @@ -129,8 +140,10 @@ int genericLauncher = 0; char *str; char *knownGenericNames[] = { "java", "java.exe", "javaw.exe", NULL }; +#ifndef HY_NO_THR char *dirs[2]; +#endif /* ! HY_NO_THR */ PORT_ACCESS_FROM_PORT (args->portLibrary); @@ -271,7 +284,11 @@ } /* Find the directory of the dll and set up the path */ +#ifndef HY_NO_THR vmdllsubdir = vmdlldir_parseCmdLine (PORTLIB, argc - 1, argv); +#else /* HY_NO_THR */ + vmdllsubdir = vmdlldir_parseCmdLine (argc - 1, argv); +#endif /* HY_NO_THR */ if (!vmdllsubdir) { vmdllsubdir = defaultDirName; } @@ -309,6 +326,7 @@ strcat (vmiPath, DIR_SEPERATOR_STRING); strcat (vmiPath, vmdll); +#ifndef HY_NO_THR dirs[0] = newPathToAdd; dirs[1] = exeName; @@ -320,6 +338,7 @@ goto bail; } +#endif /* ! HY_NO_THR */ if (showVersion == 1) { if (!versionWritten) @@ -566,7 +585,11 @@ * if the argument cannot be found. */ char *VMCALL +#ifndef HY_NO_THR vmdlldir_parseCmdLine (HyPortLibrary * portLibrary, UDATA lastLegalArg, +#else /* HY_NO_THR */ +vmdlldir_parseCmdLine (UDATA lastLegalArg, +#endif /* HY_NO_THR */ char **argv) { UDATA i; @@ -1003,7 +1026,11 @@ * */ static IDATA +#ifndef HY_NO_THR addDirsToPath (HyPortLibrary * portLibrary, int count, char *newPathToAdd[], char **argv) +#else /* HY_NO_THR */ +addDirsToPath (int count, char *newPathToAdd[], char **argv) +#endif /* HY_NO_THR */ { char *oldPath = NULL; char *variableName = NULL; @@ -1015,9 +1042,13 @@ int i=0; int strLen; +#ifndef HY_NO_THR PORT_ACCESS_FROM_PORT (portLibrary); hysysinfo_get_executable_name (argv[0], &exeName); +#else /* HY_NO_THR */ + main_get_executable_name (argv[0], &exeName); +#endif /* HY_NO_THR */ #if defined(WIN32) variableName = "PATH"; @@ -1066,7 +1097,11 @@ } } +#ifndef HY_NO_THR newPath = hymem_allocate_memory(strLen + 1); +#else /* HY_NO_THR */ + newPath = main_mem_allocate_memory(strLen + 1); +#endif /* HY_NO_THR */ strcpy (newPath, variableName); strcat (newPath, "="); @@ -1456,3 +1491,69 @@ return NULL; } +#ifdef HY_NO_THR + + +int +main_addVMDirToPath(int argc, char **argv, char **envp) +{ + char *vmdllsubdir; + char *newPathToAdd = NULL; + char *propertiesFileName = NULL; + char *exeName = NULL; + char *exeBaseName; + char *endPathPtr; + char defaultDirName[] = "default"; + int rc = -1; + char *dirs[2]; + + /* Find out name of the executable we are running as */ + main_get_executable_name (argv[0], &exeName); + + /* Pick out the end of the exe path, and start of the basename */ + exeBaseName = strrchr(exeName, HY_PATH_SLASH); + if (exeBaseName == NULL) { + endPathPtr = exeBaseName = exeName; + } else { + exeBaseName += 1; + endPathPtr = exeBaseName; + } + + /* Find the directory of the dll and set up the path */ + vmdllsubdir = vmdlldir_parseCmdLine (argc - 1, argv); + if (!vmdllsubdir) { + vmdllsubdir = defaultDirName; + } + + /* jvm dlls are located in a subdirectory off of jre/bin */ + /* setup path to dll named in -vm argument */ + endPathPtr[0] = '\0'; + + newPathToAdd = main_mem_allocate_memory (strlen (exeName) + strlen (vmdllsubdir) + 1); + + if (newPathToAdd == NULL) { + goto bail; + } + + strcpy (newPathToAdd, exeName); + strcat (newPathToAdd, vmdllsubdir); + + dirs[0] = newPathToAdd; + dirs[1] = exeName; + + printf( "RON newPathToAdd: %s exeName: %s\n", newPathToAdd, exeName ); + + rc = addDirsToPath(2, dirs, argv); + +bail: + if (exeName) { + main_mem_free_memory (exeName); + } + + if (newPathToAdd) { + main_mem_free_memory (newPathToAdd); + } + // error code should be equal to 1 because of compatibility + return rc == 0 ? 0 : 1; +} +#endif /* HY_NO_THR */ Index: modules/luni/src/main/native/launcher/shared/cmain.c =================================================================== --- modules/luni/src/main/native/launcher/shared/cmain.c (revision 514702) +++ modules/luni/src/main/native/launcher/shared/cmain.c (working copy) @@ -17,7 +17,13 @@ #include "hycomp.h" #include "hyport.h" +#ifdef HY_NO_THR +#include "main_hlp.h" +#endif /* HY_NO_THR */ #include /* for malloc for atoe and abort */ +#ifdef HY_NO_THR +#include +#endif /* HY_NO_THR */ struct haCmdlineOptions { @@ -27,6 +33,9 @@ HyPortLibrary *portLibrary; }; extern UDATA VMCALL gpProtectedMain (void *arg); +#ifdef HY_NO_THR +extern int main_addVMDirToPath(int argc, char **argv, char **envp); +#endif /* HY_NO_THR */ static UDATA VMCALL genericSignalHandler (struct HyPortLibrary *portLibrary, U_32 gpType, @@ -80,6 +89,12 @@ return gpProtectedMain (arg); } +#ifdef HY_NO_THR +typedef I_32 (PVMCALL hyport_init_library_type) (struct HyPortLibrary *portLibrary, + struct HyPortLibraryVersion *version, + UDATA size); + +#endif /* HY_NO_THR */ int main (int argc, char **argv, char **envp) { @@ -88,13 +103,37 @@ struct haCmdlineOptions options; int rc = 257; UDATA result; +#ifndef HY_NO_THR +#else /* HY_NO_THR */ + UDATA portLibDescriptor; + hyport_init_library_type port_init_library_func; + + /* determine which VM directory to use and add it to the path */ + rc = main_addVMDirToPath(argc, argv, envp); + if ( 0 != rc ) { + return rc; + } + + if ( 0 != main_open_port_library(&portLibDescriptor) ) { + fprintf( stderr, "failed to open hyprt library.\n" ); + return -1; + } + if ( 0 != main_lookup_name( portLibDescriptor, "hyport_init_library", (UDATA *)&port_init_library_func) ) { + fprintf( stderr, "failed to find hyport_init_library function in hyprt library\n" ); + return -1; + } +#endif /* HY_NO_THR */ /* Use portlibrary version which we compiled against, and have allocated space * for on the stack. This version may be different from the one in the linked DLL. */ HYPORT_SET_VERSION (&portLibraryVersion, HYPORT_CAPABILITY_MASK); if (0 == +#ifndef HY_NO_THR hyport_init_library (&hyportLibrary, &portLibraryVersion, +#else /* HY_NO_THR */ + port_init_library_func (&hyportLibrary, &portLibraryVersion, +#endif /* HY_NO_THR */ sizeof (HyPortLibrary))) { options.argc = argc; Index: modules/luni/src/main/native/launcher/shared/main_hlp.h =================================================================== --- modules/luni/src/main/native/launcher/shared/main_hlp.h (revision 0) +++ modules/luni/src/main/native/launcher/shared/main_hlp.h (revision 0) @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if !defined(MAINHLP_H) +#define MAINHLP_H +#if defined(__cplusplus) +extern "C" +{ +#endif +#include "hycomp.h" + +extern HY_CFUNC int main_get_executable_name PROTOTYPE((char *argv0, char **exeName)); +extern HY_CFUNC void *main_mem_allocate_memory PROTOTYPE((int byteAmount)); +extern HY_CFUNC void main_mem_free_memory PROTOTYPE((void *memoryPointer)); +extern HY_CFUNC int main_open_port_library PROTOTYPE((UDATA * descriptor)); +extern HY_CFUNC int main_close_port_library PROTOTYPE((UDATA descriptor)); +extern HY_CFUNC UDATA main_lookup_name PROTOTYPE((UDATA descriptor, char *name, UDATA * func)); + +#if defined(__cplusplus) +} +#endif +#endif /* MAINHLP_H */ Property changes on: modules/luni/src/main/native/launcher/shared/main_hlp.h ___________________________________________________________________ Name: svn:eol-style + native Index: modules/luni/src/main/native/launcher/windows/makefile.javae =================================================================== --- modules/luni/src/main/native/launcher/windows/makefile.javae (revision 514702) +++ modules/luni/src/main/native/launcher/windows/makefile.javae (working copy) @@ -24,9 +24,14 @@ BUILDFILES = $(SHAREDSUB)launcher_copyright.obj $(SHAREDSUB)cmain.obj \ $(SHAREDSUB)main.obj $(SHAREDSUB)strbuf.obj $(SHAREDSUB)libhlp.obj +!IF "$(HY_NO_THR)" == "false" +MDLLIBFILES = $(MDLLIBFILES) $(LIBPATH)hyprt.lib +!ELSE +BUILDFILES = $(BUILDFILES) main_hlp.obj +!ENDIF + VIRTFILES = java.res EXEFLAGS=$(conlflags) -subsystem:console EXEDLLFILES=$(conlibsdll) -MDLLIBFILES = $(MDLLIBFILES) $(LIBPATH)hyprt.lib !include <$(HY_HDK)\build\make\rules.mak> Index: modules/luni/src/main/native/launcher/windows/winmain.c =================================================================== --- modules/luni/src/main/native/launcher/windows/winmain.c (revision 514702) +++ modules/luni/src/main/native/launcher/windows/winmain.c (working copy) @@ -19,16 +19,30 @@ #include "jni.h" #include "hyport.h" //#include "libhlp.h" +#ifdef HY_NO_THR +#include "main_hlp.h" +#endif /* HY_NO_THR */ /* external prototypes */ UDATA VMCALL gpProtectedMain PROTOTYPE ((void *arg)); +#ifdef HY_NO_THR +extern int main_addVMDirToPath PROTOTYPE((int argc, char **argv, char **envp)); +#endif /* HY_NO_THR */ char **getArgvCmdLine +#ifndef HY_NO_THR PROTOTYPE ((HyPortLibrary * portLibrary, LPTSTR buffer, int *finalArgc)); +#else /* HY_NO_THR */ +PROTOTYPE ((LPTSTR buffer, int *finalArgc)); +#endif /* HY_NO_THR */ int WINAPI WinMain PROTOTYPE ((HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)); +#ifndef HY_NO_THR void freeArgvCmdLine PROTOTYPE ((HyPortLibrary * portLibrary, char **argv)); +#else /* HY_NO_THR */ +void freeArgvCmdLine PROTOTYPE ((char **argv)); +#endif /* HY_NO_THR */ struct haCmdlineOptions { @@ -38,6 +52,13 @@ HyPortLibrary *portLibrary; }; +#ifdef HY_NO_THR +typedef I_32 (PVMCALL hyport_init_library_type) (struct HyPortLibrary *portLibrary, + struct HyPortLibraryVersion *version, + UDATA size); + + +#endif /* HY_NO_THR */ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd) @@ -47,12 +68,41 @@ HyPortLibraryVersion portLibraryVersion; struct haCmdlineOptions options; char **argv; +#ifdef HY_NO_THR + UDATA portLibDescriptor; + hyport_init_library_type port_init_library_func; + + argv = getArgvCmdLine (GetCommandLine (), &argc); + if (argv == NULL) { + rc = -1; + goto cleanup; + } + /* determine which VM directory to use and add it to the path */ + rc = main_addVMDirToPath(argc, argv, NULL); + if ( rc != 0 ) { + goto cleanup; + } + + if ( 0 != main_open_port_library(&portLibDescriptor) ) { + fprintf( stderr, "failed to open hyprt library.\n" ); + rc = -1; + goto cleanup; + } + + if ( 0 != main_lookup_name( portLibDescriptor, "hyport_init_library", (UDATA *)&port_init_library_func) ) { + fprintf( stderr, "failed to find hyport_init_library function in hyprt library\n" ); + rc = -1; + goto cleanup; + } +#endif /* HY_NO_THR */ + /* Use portlibrary version which we compiled against, and have allocated space * for on the stack. This version may be different from the one in the linked DLL. */ HYPORT_SET_VERSION (&portLibraryVersion, HYPORT_CAPABILITY_MASK); +#ifndef HY_NO_THR rc = hyport_init_library (&hyportLibrary, &portLibraryVersion, sizeof (HyPortLibrary)); @@ -78,6 +128,25 @@ { return -1; } +#else /* HY_NO_THR */ + rc = port_init_library_func (&hyportLibrary, &portLibraryVersion, sizeof (HyPortLibrary)); + if (0 != rc) { + goto cleanup; + } + + options.argc = argc; + options.argv = argv; + options.envp = NULL; + options.portLibrary = &hyportLibrary; + rc = hyportLibrary.gp_protect (&hyportLibrary, gpProtectedMain, &options); + hyportLibrary.port_shutdown_library (&hyportLibrary); + +cleanup: + if (argv) { + freeArgvCmdLine(argv); + } + return rc; +#endif /* HY_NO_THR */ } /* @@ -87,7 +156,11 @@ * also converts the string to ASCII. */ char ** +#ifndef HY_NO_THR getArgvCmdLine (HyPortLibrary * portLibrary, LPTSTR buffer, int *finalArgc) +#else /* HY_NO_THR */ +getArgvCmdLine (LPTSTR buffer, int *finalArgc) +#endif /* HY_NO_THR */ { #define QUOTE_CHAR 34 @@ -95,7 +168,9 @@ int argc = 0, currentArg, i, asciiLen; char *asciiCmdLine; char **argv; +#ifndef HY_NO_THR PORT_ACCESS_FROM_PORT (portLibrary); +#endif /* ! HY_NO_THR */ asciiCmdLine = buffer; @@ -109,7 +184,11 @@ } /* allocate the buffer for the args */ +#ifndef HY_NO_THR argv = hymem_allocate_memory (argc * sizeof (char *)); +#else /* HY_NO_THR */ + argv = main_mem_allocate_memory (argc * sizeof (char *)); +#endif /* HY_NO_THR */ if (!argv) return NULL; @@ -168,9 +247,17 @@ #undef QUOTE_CHAR void +#ifndef HY_NO_THR freeArgvCmdLine (HyPortLibrary * portLibrary, char **argv) +#else /* HY_NO_THR */ +freeArgvCmdLine (char **argv) +#endif /* HY_NO_THR */ { +#ifndef HY_NO_THR PORT_ACCESS_FROM_PORT (portLibrary); hymem_free_memory (argv); +#else /* HY_NO_THR */ + main_mem_free_memory (argv); +#endif /* HY_NO_THR */ } Index: modules/luni/src/main/native/launcher/windows/makefile.javaw =================================================================== --- modules/luni/src/main/native/launcher/windows/makefile.javaw (revision 514702) +++ modules/luni/src/main/native/launcher/windows/makefile.javaw (working copy) @@ -20,11 +20,17 @@ !include <$(HY_HDK)\build\make\defines.mak> EXENAME=$(EXEPATH)javaw.exe +HYCFLAGS = $(HYCFLAGS) /I$(SHAREDSUB) + BUILDFILES = $(SHAREDSUB)launcher_copyright.obj $(SHAREDSUB)main.obj \ winmain.obj $(SHAREDSUB)strbuf.obj $(SHAREDSUB)libhlp.obj +!IF "$(HY_NO_THR)" == "false" +MDLLIBFILES = $(MDLLIBFILES) $(LIBPATH)hyprt.lib +!ELSE +BUILDFILES = $(BUILDFILES) main_hlp.obj +!ENDIF VIRTFILES = javaw.res EXEFLAGS=$(guilflags) -subsystem:windows EXEDLLFILES=$(guilibsdll) -MDLLIBFILES = $(MDLLIBFILES) $(LIBPATH)hyprt.lib !include <$(HY_HDK)\build\make\rules.mak> Index: modules/luni/src/main/native/launcher/windows/main_hlp.c =================================================================== --- modules/luni/src/main/native/launcher/windows/main_hlp.c (revision 0) +++ modules/luni/src/main/native/launcher/windows/main_hlp.c (revision 0) @@ -0,0 +1,171 @@ +#include +#include +#include +#include + +#include "main_hlp.h" + +int +main_get_executable_name (char *argv0, char **result) +{ + char *temp; + TCHAR osTemp[_MAX_PATH + 2]; + DWORD length; + + (void) argv0; /* unused */ + + length = GetModuleFileName (NULL, osTemp, _MAX_PATH + 1); + if (!length || (length >= _MAX_PATH)) + { + return -1; + } + osTemp[length] = (TCHAR) '\0'; /* jic */ + +#if defined(UNICODE) + length = + WideCharToMultiByte (CP_ACP, WC_COMPOSITECHECK, osTemp, -1, NULL, 0, NULL, + NULL); + temp = main_mem_allocate_memory (length + 1); + if (!temp) + { + return -1; + } + length = + WideCharToMultiByte (CP_ACP, WC_COMPOSITECHECK, osTemp, -1, temp, length, + NULL, NULL); +#else + temp = main_mem_allocate_memory (length + 1); + if (!temp) + { + return -1; + } + strcpy (temp, osTemp); +#endif + +*result = temp; +return 0; +} + +void * +main_mem_allocate_memory(int byteAmount) +{ + void *pointer = NULL; + if (byteAmount == 0) + { /* prevent GlobalLock from failing causing allocate to return null */ + byteAmount = 1; + } + pointer = HeapAlloc (GetProcessHeap(), 0, byteAmount); + return pointer; +} + +void +main_mem_free_memory(void *memoryPointer) +{ + HeapFree (GetProcessHeap(), 0, memoryPointer); +} + +#if !defined(HINSTANCE_ERROR) +#define HINSTANCE_ERROR 32 +#endif + +static UDATA +EsSharedLibraryLookupName (UDATA descriptor, char *name, UDATA * func) +{ + UDATA lpfnFunction; + + if (descriptor < HINSTANCE_ERROR) + { + return 3; + } + lpfnFunction = + (UDATA) GetProcAddress ((HINSTANCE) descriptor, (LPCSTR) name); + if (lpfnFunction == (UDATA) NULL) + { + return 4; + } + *func = lpfnFunction; + return 0; +} + +/** + * Opens the port library. + * + * @param[out] descriptor Pointer to memory which is filled in with shared-library handle on success. + * + * @return 0 on success, any other value on failure. + * + * @note contents of descriptor are undefined on failure. + */ +int +main_open_port_library (UDATA * descriptor) +{ + HINSTANCE dllHandle; + UINT prevMode; + + prevMode = SetErrorMode (SEM_NOOPENFILEERRORBOX | SEM_FAILCRITICALERRORS); + + /* LoadLibrary will try appending .DLL if necessary */ + dllHandle = LoadLibrary ("hyprt"); + if (dllHandle >= (HINSTANCE) HINSTANCE_ERROR) + { + *descriptor = (UDATA) dllHandle; + SetErrorMode (prevMode); + return 0; + } + return -1; +} + +/** + * Close the port library. + * + * @param[in] descriptor Shared library handle to close. + * + * @return 0 on success, any other value on failure. + */ +int +main_close_port_library (UDATA descriptor) +{ + if (descriptor < HINSTANCE_ERROR) + { + return 2; + } + FreeLibrary ((HINSTANCE) descriptor); + return 0; +} + +/** + * Search for a function named 'name' taking argCount in the shared library 'descriptor'. + * + * @param[in] descriptor Shared library to search. + * @param[in] name Function to look up. + * @param[out] func Pointer to the function. + * + * @return 0 on success, any other value on failure. + * + * argSignature is a C (ie: NUL-terminated) string with the following possible values for each character: + * + * V - void + * Z - boolean + * B - byte + * C - char (16 bits) + * I - integer (32 bits) + * J - long (64 bits) + * F - float (32 bits) + * D - double (64 bits) + * L - object / pointer (32 or 64, depending on platform) + * P - pointer-width platform data. (in this context an IDATA) + * + * Lower case signature characters imply unsigned value. + * Upper case signature characters imply signed values. + * If it doesn't make sense to be signed/unsigned (eg: V, L, F, D Z) the character is upper case. + * + * argList[0] is the return type from the function. + * The argument list is as it appears in english: list is left (1) to right (argCount) + * + * @note contents of func are undefined on failure. + */ +UDATA +main_lookup_name (UDATA descriptor, char *name, UDATA * func) +{ + return EsSharedLibraryLookupName (descriptor, name, func); +} \ No newline at end of file Property changes on: modules/luni/src/main/native/launcher/windows/main_hlp.c ___________________________________________________________________ Name: svn:eol-style + native Index: modules/luni/src/main/native/vmls/shared/vmls.c =================================================================== --- modules/luni/src/main/native/vmls/shared/vmls.c (revision 514702) +++ modules/luni/src/main/native/vmls/shared/vmls.c (working copy) @@ -77,6 +77,9 @@ */ void JNICALL HyVMLSFreeKeys(JNIEnv * env, UDATA * pInitCount, ...) { +#if defined(HY_NO_THR) + THREAD_ACCESS_FROM_ENV(env); +#endif /* HY_NO_THR */ va_list args; HyVMLSTable* vmls = GLOBAL_DATA(VMLSTable); @@ -122,6 +125,9 @@ */ UDATA JNICALL HyVMLSAllocKeys(JNIEnv * env, UDATA * pInitCount, ...) { +#if defined(HY_NO_THR) + THREAD_ACCESS_FROM_ENV(env); +#endif /* HY_NO_THR */ va_list args; HyVMLSTable *vmls = GLOBAL_DATA(VMLSTable); @@ -259,6 +265,9 @@ */ void initializeVMLocalStorage(JavaVM * vm) { +#if defined(HY_NO_THR) + THREAD_ACCESS_FROM_JAVAVM(vm); +#endif /* HY_NO_THR */ HyVMLSTable* vmls = GLOBAL_DATA(VMLSTable); VMLSContainer* container = NULL; @@ -318,6 +327,9 @@ VMLSContainer* previous = NULL; /* Reach for the VM interface */ +#if defined(HY_NO_THR) + THREAD_ACCESS_FROM_JAVAVM(vm); +#endif /* HY_NO_THR */ PORT_ACCESS_FROM_JAVAVM(vm); /* Obtain the global lock */ Index: modules/portlib/src/main/native/include/shared/hyport.h =================================================================== --- modules/portlib/src/main/native/include/shared/hyport.h (revision 514702) +++ modules/portlib/src/main/native/include/shared/hyport.h (working copy) @@ -33,6 +33,7 @@ #include #endif +struct HyPortLibrary; /** * @name Port library access * @anchor PortAccess @@ -58,8 +59,6 @@ #define PORT_ACCESS_FROM_VMI(vmi) HyPortLibrary *privatePortLibrary = (*vmi)->GetPortLibrary(vmi) #define PORT_ACCESS_FROM_PORT(portLibrary) HyPortLibrary *privatePortLibrary = (portLibrary) -/** @} */ - #define HY_STR_(x) #x #define HY_STR(x) HY_STR_(x) #define HY_GET_CALLSITE() __FILE__ ":" HY_STR(__LINE__) @@ -1001,7 +1000,10 @@ /** see @ref hyfile.c::hybuf_write_text "hybuf_write_text"*/ char *(PVMCALL buf_write_text) (struct HyPortLibrary * portLibrary, const char *buf, IDATA nbytes); - +#if defined(HY_NO_THR) + /** see @ref hyport.c::hyport_get_thread_library "hyport_get_thread_library" */ + HyThreadLibrary * (PVMCALL port_get_thread_library) (struct HyPortLibrary * portLibrary); +#endif /* HY_NO_THR */ char _hypadding039C[4]; /* 4 bytes of automatic padding */ } HyPortLibrary; #define HYPORT_SL_FOUND 0 @@ -1031,7 +1033,11 @@ #define HYPORT_CTLDATA_TRACE_STOP "TRACE_STOP" #define HYPORT_CTLDATA_SHMEM_GROUP_PERM "SHMEM_GROUP_PERM" #define HYPORT_MAJOR_VERSION_NUMBER 4 +#if defined(HY_NO_THR) +#define HYPORT_MINOR_VERSION_NUMBER 1 +#else #define HYPORT_MINOR_VERSION_NUMBER 0 +#endif #define HYPORT_CAPABILITY_BASE 0 #define HYPORT_CAPABILITY_STANDARD 1 #define HYPORT_CAPABILITY_FILESYSTEM 2 @@ -1185,6 +1191,9 @@ * @{ */ #if !defined(HYPORT_LIBRARY_DEFINE) +#if defined(HY_NO_THR) +#define hyport_get_thread_library() privatePortLibrary->port_get_thread_library(privatePortLibrary) +#endif #define hyport_shutdown_library() privatePortLibrary->port_shutdown_library(privatePortLibrary) #define hyport_isFunctionOverridden(param1) privatePortLibrary->port_isFunctionOverridden(privatePortLibrary,param1) #define hyport_tls_free() privatePortLibrary->port_tls_free(privatePortLibrary) Index: modules/portlib/src/main/native/port/unix/hysignal.c =================================================================== --- modules/portlib/src/main/native/port/unix/hysignal.c (revision 514702) +++ modules/portlib/src/main/native/port/unix/hysignal.c (working copy) @@ -222,7 +222,11 @@ void *fn_arg, hysig_handler_fn handler, void *handler_arg, U_32 flags, UDATA * result) { +#ifndef HY_NO_THR +#else /* HY_NO_THR */ + THREAD_ACCESS_FROM_PORT(portLibrary); +#endif /* HY_NO_THR */ struct HySignalHandlerRecord thisRecord; hythread_t thisThread; U_32 rc = 0; Index: modules/portlib/src/main/native/port/shared/hynls.c =================================================================== --- modules/portlib/src/main/native/port/shared/hynls.c (revision 514702) +++ modules/portlib/src/main/native/port/shared/hynls.c (working copy) @@ -83,6 +83,9 @@ hynls_set_locale (struct HyPortLibrary *portLibrary, const char *lang, const char *region, const char *variant) { +#ifdef HY_NO_THR + THREAD_ACCESS_FROM_PORT(portLibrary); +#endif /* HY_NO_THR */ HyNLSDataCache *nls = &portLibrary->portGlobals->nls_data; #if defined(NLS_DEBUG_TRACE) @@ -265,6 +268,9 @@ U_32 module_name, U_32 message_num, const char *default_string) { +#ifdef HY_NO_THR + THREAD_ACCESS_FROM_PORT(portLibrary); +#endif /* HY_NO_THR */ HyNLSDataCache *nls = &portLibrary->portGlobals->nls_data; const char *message; #if defined(NLS_DEBUG_TRACE) @@ -313,6 +319,9 @@ const int nPaths, const char *baseName, const char *extension) { +#ifdef HY_NO_THR + THREAD_ACCESS_FROM_PORT(portLibrary); +#endif /* HY_NO_THR */ int i; char *p; @@ -1078,6 +1087,9 @@ I_32 VMCALL hynls_startup (struct HyPortLibrary *portLibrary) { +#ifdef HY_NO_THR + THREAD_ACCESS_FROM_PORT(portLibrary); +#endif /* HY_NO_THR */ HyNLSDataCache *nls = &portLibrary->portGlobals->nls_data; if (0 != @@ -1105,6 +1117,9 @@ void VMCALL hynls_shutdown (struct HyPortLibrary *portLibrary) { +#ifdef HY_NO_THR + THREAD_ACCESS_FROM_PORT(portLibrary); +#endif /* HY_NO_THR */ HyNLSDataCache *nls = &portLibrary->portGlobals->nls_data; HyNLSHashEntry *entry; U_32 i; Index: modules/portlib/src/main/native/port/shared/hyport.c =================================================================== --- modules/portlib/src/main/native/port/shared/hyport.c (revision 514702) +++ modules/portlib/src/main/native/port/shared/hyport.c (working copy) @@ -73,6 +73,10 @@ I_32 VMCALL hyport_shutdown_library (struct HyPortLibrary * portLibrary) { +#ifdef HY_NO_THR + THREAD_ACCESS_FROM_PORT(portLibrary); + +#endif /* HY_NO_THR */ #if !defined(HY_NO_SIG) portLibrary->sig_shutdown (portLibrary); #endif /* HY_NO_SIG */ @@ -202,9 +206,31 @@ hyport_startup_library (struct HyPortLibrary * portLibrary) { I_32 rc = 0; +#ifdef HY_NO_THR + HyThreadLibrary *hyThreadLibrary; + HyThreadLibraryVersion hyThreadLibraryVersion; + + HYTHREAD_SET_VERSION(&hyThreadLibraryVersion, HYTHREAD_CAPABILITY_MASK); + rc = hythread_allocate_library(&hyThreadLibraryVersion, &hyThreadLibrary); + if ( 0 != rc ) { + rc = HYPORT_ERROR_STARTUP_THREAD; + goto cleanup; + } + rc = hythread_startup_library(hyThreadLibrary); + if ( 0 != rc ) + { + rc = HYPORT_ERROR_STARTUP_THREAD; + goto cleanup; + } +#endif /* HY_NO_THR */ + /* NLS uses the thread library */ +#ifndef HY_NO_THR rc = hythread_attach (&portLibrary->attached_thread); +#else /* HY_NO_THR */ + rc = hyThreadLibrary->thread_attach (hyThreadLibrary, &portLibrary->attached_thread); +#endif /* HY_NO_THR */ if (0 != rc) { /* Reassign return code as hythread_attach only returns -1 on error */ @@ -220,6 +246,11 @@ goto cleanup; } +#ifdef HY_NO_THR + /* Store threadLibrary in port globals */ + portLibrary->portGlobals->threadLibrary = hyThreadLibrary; + +#endif /* HY_NO_THR */ /* Create the tls buffers as early as possible */ rc = hyport_tls_startup (portLibrary); if (0 != rc) @@ -543,6 +574,14 @@ return rc; } +#ifdef HY_NO_THR +HyThreadLibrary * VMCALL +hyport_get_thread_library(HyPortLibrary * portLib) +{ + return portLib->portGlobals->threadLibrary; +} + +#endif /* HY_NO_THR */ /* Set up the NLS catalog. This must be called prior to attempting * any nls_printf() calls on the port library. */ Index: modules/portlib/src/main/native/port/shared/hytlshelpers.c =================================================================== --- modules/portlib/src/main/native/port/shared/hytlshelpers.c (revision 514702) +++ modules/portlib/src/main/native/port/shared/hytlshelpers.c (working copy) @@ -49,6 +49,9 @@ void *VMCALL hyport_tls_get (struct HyPortLibrary *portLibrary) { +#ifdef HY_NO_THR + THREAD_ACCESS_FROM_PORT(portLibrary); +#endif /* HY_NO_THR */ PortlibPTBuffers_t ptBuffers; ptBuffers = @@ -97,6 +100,9 @@ void VMCALL hyport_tls_free (struct HyPortLibrary *portLibrary) { +#ifdef HY_NO_THR + THREAD_ACCESS_FROM_PORT(portLibrary); +#endif /* HY_NO_THR */ PortlibPTBuffers_t ptBuffers; MUTEX_ENTER (portLibrary->portGlobals->tls_mutex); @@ -147,6 +153,9 @@ I_32 VMCALL hyport_tls_startup (struct HyPortLibrary *portLibrary) { +#ifdef HY_NO_THR + THREAD_ACCESS_FROM_PORT(portLibrary); +#endif /* HY_NO_THR */ if (hythread_tls_alloc (&portLibrary->portGlobals->tls_key)) { return HYPORT_ERROR_STARTUP_TLS_ALLOC; @@ -172,6 +181,9 @@ void VMCALL hyport_tls_shutdown (struct HyPortLibrary *portLibrary) { +#ifdef HY_NO_THR + THREAD_ACCESS_FROM_PORT(portLibrary); +#endif /* HY_NO_THR */ PortlibPTBuffers_t ptBuffers, next; /* Free all remaining buffer sets */ @@ -207,6 +219,9 @@ void *VMCALL hyport_tls_peek (struct HyPortLibrary *portLibrary) { +#ifdef HY_NO_THR + THREAD_ACCESS_FROM_PORT(portLibrary); +#endif /* HY_NO_THR */ return hythread_tls_get (hythread_self (), portLibrary->portGlobals->tls_key); } Index: modules/portlib/src/main/native/port/shared/portpriv.h =================================================================== --- modules/portlib/src/main/native/port/shared/portpriv.h (revision 514702) +++ modules/portlib/src/main/native/port/shared/portpriv.h (working copy) @@ -22,6 +22,9 @@ #include "hyportpg.h" #include "hyportptb.h" #include "hyport.h" +#ifdef HY_NO_THR +#include "hythread.h" +#endif /* HY_NO_THR */ #include "hymutex.h" /* The following defines are used by hyshmem and hyshsem */ @@ -85,6 +88,9 @@ hythread_tls_key_t tls_key; MUTEX tls_mutex; void *buffer_list; +#ifdef HY_NO_THR + struct HyThreadLibrary *threadLibrary; +#endif /* HY_NO_THR */ struct HyPortPlatformGlobals platformGlobals; } HyPortLibraryGlobalData; /* HySourceHyCPUControl*/ @@ -1166,6 +1172,11 @@ hysl_up_lookup_name PROTOTYPE ((struct HyPortLibrary * portLibrary, UDATA descriptor, char *name, UDATA * func, const char *argSignature)); +#ifdef HY_NO_THR +extern HY_CFUNC HyThreadLibrary * VMCALL + hyport_get_thread_library +PROTOTYPE ((HyPortLibrary * portLib)); +#endif /* HY_NO_THR */ static HyPortLibrary MasterPortLibraryTable = { {HYPORT_MAJOR_VERSION_NUMBER, HYPORT_MINOR_VERSION_NUMBER, 0, HYPORT_CAPABILITY_MASK}, /* portVersion */ NULL, /* portGlobals */ @@ -1414,6 +1425,9 @@ hyshmem_stat, /* shmem_stat */ hysysinfo_get_processing_capacity, /* sysinfo_get_processing_capacity */ hybuf_write_text, /* buf_write_text */ +#ifdef HY_NO_THR + hyport_get_thread_library, /* port_get_thread_library */ +#endif /* HY_NO_THR */ }; #endif Index: modules/portlib/src/main/native/port/windows/hysignal.c =================================================================== --- modules/portlib/src/main/native/port/windows/hysignal.c (revision 514702) +++ modules/portlib/src/main/native/port/windows/hysignal.c (working copy) @@ -18,6 +18,9 @@ #include #include #include "hyport.h" +#ifdef HY_NO_THR +#include "portpriv.h" +#endif /* HY_NO_THR */ #include "hythread.h" #include "hysignal.h" @@ -63,6 +66,9 @@ static U_32 countInfoInCategory (struct HyPortLibrary *portLibrary, void *info, U_32 category); +#ifdef HY_NO_THR +static HyThreadLibrary * threadLibraryForConsoleCtrlHandler; +#endif /* HY_NO_THR */ static BOOL WINAPI consoleCtrlHandler (DWORD dwCtrlType); int structuredExceptionHandler (struct HyPortLibrary *portLibrary, @@ -142,6 +148,9 @@ hysig_handler_fn handler, void *handler_arg, U_32 flags) { +#ifdef HY_NO_THR + THREAD_ACCESS_FROM_PORT(portLibrary); +#endif /* HY_NO_THR */ U_32 rc = 0; HyWin32AsyncHandlerRecord *cursor; HyWin32AsyncHandlerRecord **previousLink; @@ -170,6 +179,10 @@ /* if this is the last handler, unregister the Win32 handler function */ if (asyncHandlerList == NULL) { +#ifdef HY_NO_THR + /* The static function consoleCtrlHandler needs a threadLibrary */ + threadLibraryForConsoleCtrlHandler = privateThreadLibrary; +#endif /* HY_NO_THR */ SetConsoleCtrlHandler (consoleCtrlHandler, FALSE); } } @@ -206,6 +219,10 @@ /* if this is the first handler, register the Win32 handler function */ if (asyncHandlerList == NULL) { +#ifdef HY_NO_THR + /* The static function consoleCtrlHandler needs a threadLibrary */ + threadLibraryForConsoleCtrlHandler = privateThreadLibrary; +#endif /* HY_NO_THR */ SetConsoleCtrlHandler (consoleCtrlHandler, TRUE); } @@ -252,6 +269,10 @@ void VMCALL hysig_shutdown (struct HyPortLibrary *portLibrary) { +#ifdef HY_NO_THR + THREAD_ACCESS_FROM_PORT(portLibrary); + +#endif /* HY_NO_THR */ hythread_monitor_t globalMonitor = hythread_global_monitor (); removeAsyncHandlers (portLibrary); @@ -275,6 +296,9 @@ I_32 VMCALL hysig_startup (struct HyPortLibrary *portLibrary) { +#ifdef HY_NO_THR + THREAD_ACCESS_FROM_PORT(portLibrary); +#endif /* HY_NO_THR */ hythread_monitor_t globalMonitor = hythread_global_monitor (); I_32 result = 0; @@ -676,6 +700,10 @@ static BOOL WINAPI consoleCtrlHandler (DWORD dwCtrlType) { +#ifdef HY_NO_THR + THREAD_ACCESS_FROM_THREAD(threadLibraryForConsoleCtrlHandler); + +#endif /* HY_NO_THR */ U_32 flags; BOOL result = FALSE; @@ -735,6 +763,9 @@ static void removeAsyncHandlers (HyPortLibrary * portLibrary) { +#ifdef HY_NO_THR + THREAD_ACCESS_FROM_PORT(portLibrary); +#endif /* HY_NO_THR */ /* clean up the list of async handlers */ HyWin32AsyncHandlerRecord *cursor; HyWin32AsyncHandlerRecord **previousLink; @@ -766,6 +797,10 @@ if (asyncHandlerList == NULL) { +#ifdef HY_NO_THR + /* The static function consoleCtrlHandler needs a threadLibrary */ + threadLibraryForConsoleCtrlHandler = privateThreadLibrary; +#endif /* HY_NO_THR */ SetConsoleCtrlHandler (consoleCtrlHandler, FALSE); } Index: modules/portlib/src/main/native/port/windows/makefile =================================================================== --- modules/portlib/src/main/native/port/windows/makefile (revision 514702) +++ modules/portlib/src/main/native/port/windows/makefile (working copy) @@ -40,6 +40,7 @@ BUILDFILES = $(BUILDFILES) hysignal.obj !ENDIF +MDLLIBFILES = $(MDLLIBFILES) $(LIBPATH)hythr.lib VIRTFILES = hyprt.res SYSLIBFILES = \ Index: modules/portlib/src/main/native/thrstub/unix/exports.txt =================================================================== --- modules/portlib/src/main/native/thrstub/unix/exports.txt (revision 0) +++ modules/portlib/src/main/native/thrstub/unix/exports.txt (revision 0) @@ -0,0 +1,8 @@ +hythread_create_library +hythread_init_library +hythread_shutdown_library +hythread_startup_library +hythread_allocate_library +hythread_getSize +hythread_getVersion +hythread_isCompatible Property changes on: modules/portlib/src/main/native/thrstub/unix/exports.txt ___________________________________________________________________ Name: svn:eol-style + native Index: modules/portlib/src/main/native/thrstub/unix/DoxygenSupport.txt =================================================================== --- modules/portlib/src/main/native/thrstub/unix/DoxygenSupport.txt (revision 0) +++ modules/portlib/src/main/native/thrstub/unix/DoxygenSupport.txt (revision 0) @@ -0,0 +1,33 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +/* + * This file provides the group definitions required to create the Doxygen generated + * output for compounds. There is one group per directory (port, pool, thread, etc.). + */ + +/** + * @defgroup Thread Thread + * @brief Threading and Synchronization Library API. + * + * The threading and synchronization API describes a programmatic interface for the + * generic management and use of basic threading and synchronization functionality + * common to most operating systems. In implementation, it will usually be a thin + * abstraction layer atop already-provided operating system support for these + * features. It is in many ways analagous to a subset of the pthreads library. + * + */ + + Property changes on: modules/portlib/src/main/native/thrstub/unix/DoxygenSupport.txt ___________________________________________________________________ Name: svn:eol-style + native Index: modules/portlib/src/main/native/thrstub/unix/makefile =================================================================== --- modules/portlib/src/main/native/thrstub/unix/makefile (revision 0) +++ modules/portlib/src/main/native/thrstub/unix/makefile (revision 0) @@ -0,0 +1,29 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# +# Makefile for module 'thread' +# + +include $(HY_HDK)/build/make/defines.mk + +CFLAGS += -fpic + +BUILDFILES = $(SHAREDSUB)hythread.o + +DLLNAME = ../libhythr.so +EXPNAME = HYTHR_2.4 + +include $(HY_HDK)/build/make/rules.mk Index: modules/portlib/src/main/native/thrstub/shared/hythread.c =================================================================== --- modules/portlib/src/main/native/thrstub/shared/hythread.c (revision 0) +++ modules/portlib/src/main/native/thrstub/shared/hythread.c (revision 0) @@ -0,0 +1,94 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file + * @ingroup Thread + * @brief Threading and synchronization support + */ + +#include "hythread.h" +#include + +/** + * @name Thread library startup and shutdown functions + * @anchor ThreadStartup + * Create, initialize, startup and shutdow the thread library + * @{ + */ +/** Standard startup and shutdown (thread library allocated on stack or by application) */ +HY_CFUNC I_32 VMCALL +hythread_create_library (struct HyThreadLibrary *threadLibrary, + struct HyThreadLibraryVersion + *version, UDATA size) +{ + return -1; +} + + +HY_CFUNC I_32 VMCALL +hythread_init_library (struct HyThreadLibrary *threadLibrary, + struct HyThreadLibraryVersion *version, UDATA size) +{ + return -1; +} + +HY_CFUNC I_32 VMCALL +hythread_shutdown_library (struct HyThreadLibrary *threadLibrary) +{ + return -1; +} + +HY_CFUNC I_32 VMCALL +hythread_startup_library (struct HyThreadLibrary *threadLibrary) +{ + return -1; +} + +/** Thread library self allocation routines */ +HY_CFUNC I_32 VMCALL +hythread_allocate_library (struct HyThreadLibraryVersion*expectedVersion, + struct HyThreadLibrary **threadLibrary) +{ + return -1; +} + +/** @} */ +/** + * @name Thread library version and compatability queries + * @anchor ThreadVersionControl + * Determine thread library compatability and version. + * @{ + */ +HY_CFUNC UDATA VMCALL +hythread_getSize (struct HyThreadLibraryVersion *version) +{ + return 0; +} + +HY_CFUNC I_32 VMCALL +hythread_getVersion (struct HyThreadLibrary *threadLibrary, + struct HyThreadLibraryVersion *version) +{ + return -1; +} + +HY_CFUNC I_32 VMCALL +hythread_isCompatible (struct HyThreadLibraryVersion *expectedVersion) +{ + return -1; +} Property changes on: modules/portlib/src/main/native/thrstub/shared/hythread.c ___________________________________________________________________ Name: svn:eol-style + native Index: modules/portlib/src/main/native/thrstub/shared/hythread.h =================================================================== --- modules/portlib/src/main/native/thrstub/shared/hythread.h (revision 0) +++ modules/portlib/src/main/native/thrstub/shared/hythread.h (revision 0) @@ -0,0 +1,229 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if !defined(HYTHREAD_H) +#define HYTHREAD_H + +#if defined(__cplusplus) +extern "C" +{ +#endif +#include +#include "hycomp.h" + +/** @} */ +/** + * @name Thread library access + * @anchor ThreadAccess + * Macros for accessing thread library + * { + */ + +#define THREAD_ACCESS_FROM_ENV(jniEnv)\ + VMInterface *threadPrivateVMI = VMI_GetVMIFromJNIEnv(jniEnv);\ + HyPortLibrary *privatePortLibForThread = (*threadPrivateVMI)->GetPortLibrary(threadPrivateVMI);\ + HyThreadLibrary *privateThreadLibrary = privatePortLibForThread->port_get_thread_library(privatePortLibForThread) + +#define THREAD_ACCESS_FROM_JAVAVM(javaVM) \ + VMInterface *threadPrivateVMI = VMI_GetVMIFromJavaVM(javaVM); \ + HyPortLibrary *privatePortLibForThread = (*threadPrivateVMI)->GetPortLibrary(threadPrivateVMI); \ + HyThreadLibrary *privateThreadLibrary = privatePortLibForThread->port_get_thread_library(privatePortLibForThread) + +#define THREAD_ACCESS_FROM_VMI(vmi) HyPortLibrary *privatePortLibForThread = (*vmi)->GetPortLibrary(vmi); \ +HyThreadLibrary *privateThreadLibrary = privatePortLibForThread->port_get_thread_library(privatePortLibForThread) + +#define THREAD_ACCESS_FROM_PORT(portLib) HyThreadLibrary *privateThreadLibrary = portLib->port_get_thread_library(portLib) + +#define THREAD_ACCESS_FROM_THREAD(threadLibrary) HyThreadLibrary *privateThreadLibrary = threadLibrary + +#define THREADLIB privateThreadLibrary +/** @} */ + +typedef UDATA hythread_tls_key_t; + +#define HYTHREAD_PROC VMCALL + +#define HYTHREAD_MAJOR_VERSION_NUMBER 1 +#define HYTHREAD_MINOR_VERSION_NUMBER 0 +#define HYTHREAD_CAPABILITY_BASE 0 +#define HYTHREAD_CAPABILITY_STANDARD 1 +#define HYTHREAD_CAPABILITY_MASK ((U_64)(HYTHREAD_CAPABILITY_STANDARD)) +#define HYTHREAD_SET_VERSION(threadLibraryVersion, capabilityMask) \ + (threadLibraryVersion)->majorVersionNumber = HYTHREAD_MAJOR_VERSION_NUMBER; \ + (threadLibraryVersion)->minorVersionNumber = HYTHREAD_MINOR_VERSION_NUMBER; \ + (threadLibraryVersion)->capabilities = (capabilityMask) +#define HYTHREAD_SET_VERSION_DEFAULT(threadLibraryVersion) \ + (threadLibraryVersion)->majorVersionNumber = HYTHREAD_MAJOR_VERSION_NUMBER; \ + (threadLibraryVersion)->minorVersionNumber = HYTHREAD_MINOR_VERSION_NUMBER; \ + (threadLibraryVersion)->capabilities = HYTHREAD_CAPABILITY_MASK + + +typedef int (HYTHREAD_PROC * hythread_entrypoint_t) (void *); +typedef struct HyThread *hythread_t; +typedef struct HyThreadMonitor *hythread_monitor_t; +typedef struct HySemaphore *hysem_t; + +typedef struct HyThreadMonitorTracing +{ + char *monitor_name; + UDATA enter_count; + UDATA slow_count; + UDATA recursive_count; + UDATA spin2_count; + UDATA yield_count; +} HyThreadMonitorTracing; + +typedef struct HyThreadLibraryVersion +{ + U_16 majorVersionNumber; + U_16 minorVersionNumber; + U_32 padding; + U_64 capabilities; +} HyThreadLibraryVersion; + +typedef struct HyThreadLibrary { + /** threadVersion */ + struct HyThreadLibraryVersion threadVersion; + + IDATA (PVMCALL sem_destroy) (struct HyThreadLibrary * threadLibrary, hysem_t s); + IDATA (PVMCALL sem_init) (struct HyThreadLibrary * threadLibrary, hysem_t * sp, I_32 initValue); + IDATA (PVMCALL sem_post) (struct HyThreadLibrary * threadLibrary, hysem_t s); + IDATA (PVMCALL sem_wait) (struct HyThreadLibrary * threadLibrary, hysem_t s); + + IDATA (PVMCALL thread_attach) (struct HyThreadLibrary * threadLibrary, hythread_t * handle); + IDATA (PVMCALL thread_create) (struct HyThreadLibrary * threadLibrary, hythread_t * handle, UDATA stacksize, UDATA priority, + UDATA suspend, hythread_entrypoint_t entrypoint, + void *entryarg); + void (PVMCALL thread_detach) (struct HyThreadLibrary * threadLibrary, hythread_t thread); + void (PVMCALL NORETURN thread_exit) (struct HyThreadLibrary * threadLibrary, hythread_monitor_t monitor); + + UDATA *(PVMCALL thread_global) (struct HyThreadLibrary * threadLibrary, char *name); + + IDATA (PVMCALL thread_monitor_destroy) (struct HyThreadLibrary * threadLibrary, hythread_monitor_t monitor); + IDATA (PVMCALL thread_monitor_enter) (struct HyThreadLibrary * threadLibrary, hythread_monitor_t monitor); + IDATA (PVMCALL thread_monitor_exit) (struct HyThreadLibrary * threadLibrary, hythread_monitor_t monitor); + IDATA (PVMCALL thread_monitor_init_with_name) (struct HyThreadLibrary * threadLibrary, hythread_monitor_t * handle, UDATA flags, char *name); + IDATA (PVMCALL thread_monitor_notify) (struct HyThreadLibrary * threadLibrary, hythread_monitor_t monitor); + IDATA (PVMCALL thread_monitor_notify_all) (struct HyThreadLibrary * threadLibrary, hythread_monitor_t monitor); + IDATA (PVMCALL thread_monitor_wait) (struct HyThreadLibrary * threadLibrary, hythread_monitor_t monitor); + + hythread_t (PVMCALL thread_self) (struct HyThreadLibrary * threadLibrary); + IDATA (PVMCALL thread_sleep) (struct HyThreadLibrary * threadLibrary, I_64 millis); + + IDATA (PVMCALL thread_tls_alloc) (struct HyThreadLibrary * threadLibrary, hythread_tls_key_t * handle); + IDATA (PVMCALL thread_tls_free) (struct HyThreadLibrary * threadLibrary, hythread_tls_key_t key); + void *(PVMCALL thread_tls_get) (struct HyThreadLibrary * threadLibrary, hythread_t thread, hythread_tls_key_t key); + IDATA (PVMCALL thread_tls_set) (struct HyThreadLibrary * threadLibrary, hythread_t thread, hythread_tls_key_t key, void *value); + /** self_handle*/ + void *self_handle; +} HyThreadLibrary; + + +/** + * @name Thread library startup and shutdown functions + * @anchor ThreadStartup + * Create, initialize, startup and shutdow the thread library + * @{ + */ +/** Standard startup and shutdown (thread library allocated on stack or by application) */ +extern HY_CFUNC I_32 VMCALL hythread_create_library (struct HyThreadLibrary + *threadLibrary, + struct HyThreadLibraryVersion + *version, UDATA size); +extern HY_CFUNC I_32 VMCALL hythread_init_library (struct HyThreadLibrary + *threadLibrary, + struct HyThreadLibraryVersion + *version, UDATA size); +extern HY_CFUNC I_32 VMCALL hythread_shutdown_library (struct HyThreadLibrary + *threadLibrary); +extern HY_CFUNC I_32 VMCALL hythread_startup_library (struct HyThreadLibrary + *threadLibrary); +/** Thread library self allocation routines */ +extern HY_CFUNC I_32 VMCALL hythread_allocate_library (struct HyThreadLibraryVersion + *expectedVersion, + struct HyThreadLibrary + **threadLibrary); + +/** @} */ +/** + * @name Thread library version and compatability queries + * @anchor ThreadVersionControl + * Determine thread library compatability and version. + * @{ + */ +extern HY_CFUNC UDATA VMCALL hythread_getSize (struct HyThreadLibraryVersion + *version); +extern HY_CFUNC I_32 VMCALL hythread_getVersion (struct HyThreadLibrary + *threadLibrary, + struct HyThreadLibraryVersion + *version); +extern HY_CFUNC I_32 VMCALL hythread_isCompatible (struct HyThreadLibraryVersion + *expectedVersion); + +/** @} */ +/** + * @name ThreadLibrary Access functions + * Convenience helpers for accessing thread library functionality. Users can + * either call functions directly via the table or by help macros. + * @code + * if (0 != threadLibrary->thread_monitor_init_with_name (threadLibrary, &nls->monitor, 0, "NLS hash table"))... + * @endcode + * @code + * THREAD_ACCESS_FROM_ENV(jniEnv); + * if (0 != hythread_monitor_init_with_name (&nls->monitor, 0, "NLS hash table")) ... + * @endcode + * @{ + */ + +#if !defined(HYTHREAD_LIBRARY_DEFINE) +#define hythread_global_monitor() (*(hythread_monitor_t*)privateThreadLibrary->thread_global(privateThreadLibrary,"global_monitor")) +#define hythread_monitor_init(pMon,flags) privateThreadLibrary->thread_monitor_init_with_name(privateThreadLibrary,pMon,flags, #pMon) + +#define hysem_destroy(param1) privateThreadLibrary->sem_destroy(privateThreadLibrary,param1) +#define hysem_init(param1,param2) privateThreadLibrary->sem_init(privateThreadLibrary,param1,param2) +#define hysem_post(param1) privateThreadLibrary->sem_post(privateThreadLibrary,param1) +#define hysem_wait(param1) privateThreadLibrary->sem_wait(privateThreadLibrary,param1) + +#define hythread_attach(param1) privateThreadLibrary->thread_attach(privateThreadLibrary,param1) +#define hythread_create(param1,param2,param3,param4,param5,param6) privateThreadLibrary->thread_create(privateThreadLibrary,param1,param2,param3,param4,param5,param6) +#define hythread_detach(param1) privateThreadLibrary->thread_detach(privateThreadLibrary,param1) +#define hythread_exit(param1) privateThreadLibrary->thread_exit(privateThreadLibrary,param1) + +#define hythread_global(param1) privateThreadLibrary->thread_global(privateThreadLibrary,param1) + +#define hythread_monitor_destroy(param1) privateThreadLibrary->thread_monitor_destroy(privateThreadLibrary,param1) +#define hythread_monitor_enter(param1) privateThreadLibrary->thread_monitor_enter(privateThreadLibrary,param1) +#define hythread_monitor_exit(param1) privateThreadLibrary->thread_monitor_exit(privateThreadLibrary,param1) +#define hythread_monitor_init_with_name(param1,param2,param3) privateThreadLibrary->thread_monitor_init_with_name(privateThreadLibrary,param1,param2,param3) +#define hythread_monitor_notify(param1) privateThreadLibrary->thread_monitor_notify(privateThreadLibrary,param1) +#define hythread_monitor_notify_all(param1) privateThreadLibrary->thread_monitor_notify_all(privateThreadLibrary,param1) +#define hythread_monitor_wait(param1) privateThreadLibrary->thread_monitor_wait(privateThreadLibrary,param1) + +#define hythread_self() privateThreadLibrary->thread_self(privateThreadLibrary) +#define hythread_sleep(param1) privateThreadLibrary->thread_sleep(privateThreadLibrary,param1) + +#define hythread_tls_alloc(param1) privateThreadLibrary->thread_tls_alloc(privateThreadLibrary,param1) +#define hythread_tls_free(param1) privateThreadLibrary->thread_tls_free(privateThreadLibrary,param1) +#define hythread_tls_get(param1,param2) privateThreadLibrary->thread_tls_get(privateThreadLibrary,param1,param2) +#define hythread_tls_set(param1,param2,param3) privateThreadLibrary->thread_tls_set(privateThreadLibrary,param1,param2,param3) + +#endif /* !HYTHREAD_LIBRARY_DEFINE */ +#if defined(__cplusplus) +} +#endif + +#endif /* HYTHREAD_H */ Property changes on: modules/portlib/src/main/native/thrstub/shared/hythread.h ___________________________________________________________________ Name: svn:eol-style + native Index: modules/portlib/src/main/native/thrstub/windows/hythr.rc =================================================================== --- modules/portlib/src/main/native/thrstub/windows/hythr.rc (revision 0) +++ modules/portlib/src/main/native/thrstub/windows/hythr.rc (revision 0) @@ -0,0 +1,47 @@ +; +; Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable +; +; Licensed under the Apache License, Version 2.0 (the "License"); +; you may not use this file except in compliance with the License. +; You may obtain a copy of the License at +; +; http://www.apache.org/licenses/LICENSE-2.0 +; +; Unless required by applicable law or agreed to in writing, software +; distributed under the License is distributed on an "AS IS" BASIS, +; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +; See the License for the specific language governing permissions and +; limitations under the License. +; + +#include +#include + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 0,1,0,0 + PRODUCTVERSION 0,1,0,0 + FILEFLAGSMASK 0x3fL + FILEFLAGS 0x0L + FILEOS VOS_NT_WINDOWS32 + FILETYPE VFT_DLL + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "CompanyName", "The Apache Software Foundation.\0" + VALUE "FileDescription", "Thread native code\0" + VALUE "FileVersion", "0.1\0" + VALUE "InternalName", "thread\0" + VALUE "LegalCopyright", "(c) Copyright 2005 The Apache Software Foundation or its licensors, as applicable.\0" + VALUE "OriginalFilename", "hythr.dll\0" + VALUE "ProductName", "Apache Harmony\0" + VALUE "ProductVersion", "0.1\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x0409, 1200 + END +END Index: modules/portlib/src/main/native/thrstub/windows/DoxygenSupport.txt =================================================================== --- modules/portlib/src/main/native/thrstub/windows/DoxygenSupport.txt (revision 0) +++ modules/portlib/src/main/native/thrstub/windows/DoxygenSupport.txt (revision 0) @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * This file provides the group definitions required to create the Doxygen generated + * output for compounds. There is one group per directory (port, pool, thread, etc.). + */ + +/** + * @defgroup Thread Thread + * @brief Threading and Synchronization Library API. + * + * The threading and synchronization API describes a programmatic interface for the + * generic management and use of basic threading and synchronization functionality + * common to most operating systems. In implementation, it will usually be a thin + * abstraction layer atop already-provided operating system support for these + * features. It is in many ways analagous to a subset of the pthreads library. + * + */ Property changes on: modules/portlib/src/main/native/thrstub/windows/DoxygenSupport.txt ___________________________________________________________________ Name: svn:eol-style + native Index: modules/portlib/src/main/native/thrstub/windows/hythr.def =================================================================== --- modules/portlib/src/main/native/thrstub/windows/hythr.def (revision 0) +++ modules/portlib/src/main/native/thrstub/windows/hythr.def (revision 0) @@ -0,0 +1,15 @@ +LIBRARY HYTHR + +SECTIONS + .data READ WRITE + .text EXECUTE READ + +EXPORTS + hythread_create_library + hythread_init_library + hythread_shutdown_library + hythread_startup_library + hythread_allocate_library + hythread_getSize + hythread_getVersion + hythread_isCompatible Index: modules/portlib/src/main/native/thrstub/windows/makefile =================================================================== --- modules/portlib/src/main/native/thrstub/windows/makefile (revision 0) +++ modules/portlib/src/main/native/thrstub/windows/makefile (revision 0) @@ -0,0 +1,36 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# +# Makefile for module 'thread' +# + +!include <$(HY_HDK)\build\make\defines.mak> + +LIBBASE=hythr +DLLNAME=..\$(LIBBASE).dll +LIBNAME=$(LIBPATH)$(LIBBASE).lib + +BUILDFILES = $(SHAREDSUB)hythread.obj + +# TOFIX $(LIBBASE).def should be a dependency on all libs +VIRTFILES = $(LIBBASE).res +HYCFLAGS = $(HYCFLAGS) /I$(SHAREDSUB) +HYLDFLAGS = $(HYLDFLAGS) -def:$(LIBBASE).def + +DLLBASE=0x11500000 +COMMENT=/comment:"Thread support library. (c) Copyright 1993, 2005 The Apache Software Foundation or its licensors, as applicable." + +!include <$(HY_HDK)\build\make\rules.mak> Index: modules/portlib/build.xml =================================================================== --- modules/portlib/build.xml (revision 514702) +++ modules/portlib/build.xml (working copy) @@ -32,6 +32,7 @@ + @@ -50,11 +51,11 @@ - + - @@ -69,9 +70,25 @@ + + + + + + + + + + + + + + + + + depends="-build-native,-build-native-sig,-build-native-thread,-build-native-thrstub,-build-native-port" /> @@ -92,7 +109,7 @@ - + @@ -104,6 +121,18 @@ + + + + + + + + + + + + @@ -118,17 +147,15 @@ - + + + - - - - Index: make/properties.xml =================================================================== --- make/properties.xml (revision 514702) +++ make/properties.xml (working copy) @@ -225,7 +225,14 @@ value="exclude.${hy.platform}.${hy.test.vm.name}.interm" /> - + + + + + + + + @@ -373,6 +380,7 @@ +