Changeset 53652 in vbox for trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_open.c
- Timestamp:
- Jan 2, 2015 12:19:17 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_open.c
r53634 r53652 24 24 */ 25 25 26 #ifndef VBOX 26 27 #include <sys/types.h> 27 28 #include <sys/modctl.h> 28 29 #include <sys/systeminfo.h> 29 #include <sys/resource.h>30 30 31 31 #include <libelf.h> … … 40 40 #include <assert.h> 41 41 42 #define _POSIX_PTHREAD_SEMANTICS 43 #include <dirent.h> 44 #undef _POSIX_PTHREAD_SEMANTICS 42 #ifndef _MSC_VER 43 # define _POSIX_PTHREAD_SEMANTICS 44 # include <dirent.h> 45 # undef _POSIX_PTHREAD_SEMANTICS 46 #endif 47 48 #else /* VBOX */ 49 # ifndef _MSC_VER 50 # include <sys/resource.h> 51 # include <unistd.h> 52 # else 53 # include <io.h> 54 # endif 55 #endif /* VBOX */ 45 56 46 57 #include <dt_impl.h> … … 662 673 int _dtrace_debug = 0; /* debug messages enabled (off) */ 663 674 const char *const _dtrace_version = DT_VERS_STRING; /* API version string */ 675 #ifndef VBOX 664 676 int _dtrace_rdvers = RD_VERSION; /* rtld_db feature version */ 677 #endif 665 678 666 679 typedef struct dt_fdlist { … … 670 683 } dt_fdlist_t; 671 684 685 686 #ifdef VBOX 687 # include <iprt/critsect.h> 688 extern RTCRITSECT dt_qsort_lock; /* dt_aggregate.c */ 689 690 void dtrace_init(void) 691 #else /* !VBOX */ 672 692 #pragma init(_dtrace_init) 673 693 void 674 694 _dtrace_init(void) 695 #endif /* !VBOX */ 675 696 { 676 697 _dtrace_debug = getenv("DTRACE_DEBUG") != NULL; 677 698 699 #ifndef VBOX 678 700 for (; _dtrace_rdvers > 0; _dtrace_rdvers--) { 679 701 if (rd_init(_dtrace_rdvers) == RD_OK) 680 702 break; 681 703 } 704 #else 705 RTCritSectInit(&dt_qsort_lock); 706 #endif 682 707 } 683 708 … … 692 717 } 693 718 719 #ifndef VBOX 694 720 static void 695 721 dt_provmod_open(dt_provmod_t **provmod, dt_fdlist_t *dfp) … … 745 771 (void) closedir(dirp); 746 772 } 773 #endif /* !VBOX */ 747 774 748 775 static void … … 763 790 dt_get_sysinfo(int cmd, char *buf, size_t len) 764 791 { 792 #ifndef VBOX 765 793 ssize_t rv = sysinfo(cmd, buf, len); 766 794 char *p = buf; … … 771 799 while ((p = strchr(p, '.')) != NULL) 772 800 *p++ = '_'; 773 801 #else 802 snprintf(buf, len, "%s", "Unknown"); 803 #endif 774 804 return (buf); 775 805 } … … 785 815 dt_provmod_t *provmod = NULL; 786 816 int i, err; 817 #ifndef _MSC_VER 787 818 struct rlimit rl; 819 #endif 788 820 789 821 const dt_intrinsic_t *dinp; … … 795 827 ctf_arinfo_t ctr; 796 828 829 #ifndef VBOX 797 830 dt_fdlist_t df = { NULL, 0, 0 }; 831 #endif 798 832 799 833 char isadef[32], utsdef[32]; 834 #ifndef VBOX 800 835 char s1[64], s2[64]; 836 #endif 801 837 802 838 if (version <= 0) … … 830 866 return (set_open_errno(dtp, errp, EINVAL)); 831 867 868 #ifndef VBOX 832 869 if (elf_version(EV_CURRENT) == EV_NONE) 833 870 return (set_open_errno(dtp, errp, EDT_ELFVERSION)); 871 #endif 834 872 835 873 if (vector != NULL || (flags & DTRACE_O_NODEV)) 836 874 goto alloc; /* do not attempt to open dtrace device */ 837 875 876 #ifndef _MSC_VER 838 877 /* 839 878 * Before we get going, crank our limit on file descriptors up to the … … 848 887 (void) setrlimit(RLIMIT_NOFILE, &rl); 849 888 } 850 889 #endif 890 891 #ifndef VBOX 851 892 /* 852 893 * Get the device path of each of the providers. We hold them open … … 892 933 (void) fcntl(dtfd, F_SETFD, FD_CLOEXEC); 893 934 (void) fcntl(ftfd, F_SETFD, FD_CLOEXEC); 935 #else /* VBOX */ 936 /** @todo open ring-0 dtrace module. */ 937 #endif /* VBOX */ 894 938 895 939 alloc: … … 926 970 dtp->dt_varg = arg; 927 971 dt_dof_init(dtp); 972 #ifndef VBOX 928 973 (void) uname(&dtp->dt_uts); 974 #endif 929 975 930 976 if (dtp->dt_mods == NULL || dtp->dt_provs == NULL || … … 941 987 (uint_t)(sizeof (void *) * NBBY)); 942 988 989 #ifndef VBOX 943 990 (void) snprintf(utsdef, sizeof (utsdef), "-D__%s_%s", 944 991 dt_get_sysinfo(SI_SYSNAME, s1, sizeof (s1)), 945 992 dt_get_sysinfo(SI_RELEASE, s2, sizeof (s2))); 993 #endif 946 994 947 995 if (dt_cpp_add_arg(dtp, "-D__sun") == NULL ||
Note:
See TracChangeset
for help on using the changeset viewer.