18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "jvm.h"
26 #include "logging/log.hpp"
27 #include "memory/allocation.inline.hpp"
28 #include "utilities/globalDefinitions.hpp"
29 #include "runtime/frame.inline.hpp"
30 #include "runtime/interfaceSupport.inline.hpp"
31 #include "runtime/os.hpp"
32 #include "services/memTracker.hpp"
33 #include "utilities/align.hpp"
34 #include "utilities/formatBuffer.hpp"
35 #include "utilities/macros.hpp"
36 #include "utilities/vmError.hpp"
37
38 #include <dlfcn.h>
39 #include <pthread.h>
40 #include <signal.h>
41 #include <sys/mman.h>
42 #include <sys/resource.h>
43 #include <sys/utsname.h>
44 #include <time.h>
45 #include <unistd.h>
46
47 // Todo: provide a os::get_max_process_id() or similar. Number of processes
48 // may have been configured, can be read more accurately from proc fs etc.
49 #ifndef MAX_PID
50 #define MAX_PID INT_MAX
51 #endif
52 #define IS_VALID_PID(p) (p > 0 && p < MAX_PID)
53
54 #define ROOT_UID 0
55
56 #ifndef MAP_ANONYMOUS
57 #define MAP_ANONYMOUS MAP_ANON
508 *limit = lower_limit;
509 }
510 return true;
511 #endif
512 }
513
514 const char* os::get_current_directory(char *buf, size_t buflen) {
515 return getcwd(buf, buflen);
516 }
517
518 FILE* os::open(int fd, const char* mode) {
519 return ::fdopen(fd, mode);
520 }
521
522 void os::flockfile(FILE* fp) {
523 ::flockfile(fp);
524 }
525
526 void os::funlockfile(FILE* fp) {
527 ::funlockfile(fp);
528 }
529
530 // Builds a platform dependent Agent_OnLoad_<lib_name> function name
531 // which is used to find statically linked in agents.
532 // Parameters:
533 // sym_name: Symbol in library we are looking for
534 // lib_name: Name of library to look in, NULL for shared libs.
535 // is_absolute_path == true if lib_name is absolute path to agent
536 // such as "/a/b/libL.so"
537 // == false if only the base name of the library is passed in
538 // such as "L"
539 char* os::build_agent_function_name(const char *sym_name, const char *lib_name,
540 bool is_absolute_path) {
541 char *agent_entry_name;
542 size_t len;
543 size_t name_len;
544 size_t prefix_len = strlen(JNI_LIB_PREFIX);
545 size_t suffix_len = strlen(JNI_LIB_SUFFIX);
546 const char *start;
547
|
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "jvm.h"
26 #include "logging/log.hpp"
27 #include "memory/allocation.inline.hpp"
28 #include "utilities/globalDefinitions.hpp"
29 #include "runtime/frame.inline.hpp"
30 #include "runtime/interfaceSupport.inline.hpp"
31 #include "runtime/os.hpp"
32 #include "services/memTracker.hpp"
33 #include "utilities/align.hpp"
34 #include "utilities/formatBuffer.hpp"
35 #include "utilities/macros.hpp"
36 #include "utilities/vmError.hpp"
37
38 #include <dirent.h>
39 #include <dlfcn.h>
40 #include <pthread.h>
41 #include <signal.h>
42 #include <sys/mman.h>
43 #include <sys/resource.h>
44 #include <sys/utsname.h>
45 #include <time.h>
46 #include <unistd.h>
47
48 // Todo: provide a os::get_max_process_id() or similar. Number of processes
49 // may have been configured, can be read more accurately from proc fs etc.
50 #ifndef MAX_PID
51 #define MAX_PID INT_MAX
52 #endif
53 #define IS_VALID_PID(p) (p > 0 && p < MAX_PID)
54
55 #define ROOT_UID 0
56
57 #ifndef MAP_ANONYMOUS
58 #define MAP_ANONYMOUS MAP_ANON
509 *limit = lower_limit;
510 }
511 return true;
512 #endif
513 }
514
515 const char* os::get_current_directory(char *buf, size_t buflen) {
516 return getcwd(buf, buflen);
517 }
518
519 FILE* os::open(int fd, const char* mode) {
520 return ::fdopen(fd, mode);
521 }
522
523 void os::flockfile(FILE* fp) {
524 ::flockfile(fp);
525 }
526
527 void os::funlockfile(FILE* fp) {
528 ::funlockfile(fp);
529 }
530
531 DIR* os::opendir(const char* dirname) {
532 assert(dirname != NULL, "just checking");
533 return ::opendir(dirname);
534 }
535
536 struct dirent* os::readdir(DIR* dirp) {
537 assert(dirp != NULL, "just checking");
538 return ::readdir(dirp);
539 }
540
541 int os::closedir(DIR *dirp) {
542 assert(dirp != NULL, "just checking");
543 return ::closedir(dirp);
544 }
545
546 // Builds a platform dependent Agent_OnLoad_<lib_name> function name
547 // which is used to find statically linked in agents.
548 // Parameters:
549 // sym_name: Symbol in library we are looking for
550 // lib_name: Name of library to look in, NULL for shared libs.
551 // is_absolute_path == true if lib_name is absolute path to agent
552 // such as "/a/b/libL.so"
553 // == false if only the base name of the library is passed in
554 // such as "L"
555 char* os::build_agent_function_name(const char *sym_name, const char *lib_name,
556 bool is_absolute_path) {
557 char *agent_entry_name;
558 size_t len;
559 size_t name_len;
560 size_t prefix_len = strlen(JNI_LIB_PREFIX);
561 size_t suffix_len = strlen(JNI_LIB_SUFFIX);
562 const char *start;
563
|