Running Perfmon3 applications on a Perfmon2 kernel may lead to invalid
syscalls. This patch adds a kernel version check to version 3
functions. Now, Perfmon3 syscalls are only executed if a Perfmon3
kernel is present, otherwise an ENOSYS error is returned.

Signed-off-by: Robert Richter <robert.rich...@amd.com>
---
 lib/pfmlib_os_linux_v3.c |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/lib/pfmlib_os_linux_v3.c b/lib/pfmlib_os_linux_v3.c
index 8187ba8..c418a64 100644
--- a/lib/pfmlib_os_linux_v3.c
+++ b/lib/pfmlib_os_linux_v3.c
@@ -60,6 +60,11 @@ pfm_create(int flags, pfarg_sinfo_t *sif, ...)
        size_t smpl_size = 0;
        int ret;
 
+       if (_pfmlib_major_version < 3) {
+               errno = ENOSYS;
+               return -1;
+       }
+
        if (flags & PFM_FL_SMPL_FMT)
                va_start(ap, sif);
        
@@ -80,35 +85,47 @@ pfm_create(int flags, pfarg_sinfo_t *sif, ...)
 int
 pfm_write(int fd, int flags, int type, void *pms, size_t sz)
 {
+       if (_pfmlib_major_version < 3)
+               return -ENOSYS;
        return (int)syscall(PFM_pfm_write, fd, flags, type, pms, sz);
 }
 
 int
 pfm_read(int fd, int flags, int type, void *pms, size_t sz)
 {
+       if (_pfmlib_major_version < 3)
+               return -ENOSYS;
        return (int)syscall(PFM_pfm_read, fd, flags, type, pms, sz);
 }
 
 int
 pfm_create_sets(int fd, int flags, pfarg_set_desc_t *setd, size_t sz)
 {
+       if (_pfmlib_major_version < 3)
+               return -ENOSYS;
        return (int)syscall(PFM_pfm_create_sets, fd, flags, setd, sz);
 }
 
 int
 pfm_getinfo_sets(int fd, int flags, pfarg_set_info_t *info, size_t sz)
 {
+       if (_pfmlib_major_version < 3)
+               return -ENOSYS;
        return (int)syscall(PFM_pfm_getinfo_sets, fd, flags, info, sz);
 }
 
 int
 pfm_attach(int fd, int flags, int target)
 {
+       if (_pfmlib_major_version < 3)
+               return -ENOSYS;
        return (int)syscall(PFM_pfm_attach, fd, flags, target);
 }
 
 int
 pfm_set_state(int fd, int flags, int state)
 {
+       if (_pfmlib_major_version < 3)
+               return -ENOSYS;
        return (int)syscall(PFM_pfm_set_state, fd, flags, state);
 }
-- 
1.6.1.2



------------------------------------------------------------------------------
Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM)
software. With Adobe AIR, Ajax developers can use existing skills and code to
build responsive, highly engaging applications that combine the power of local
resources and data with the reach of the web. Download the Adobe AIR SDK and
Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com
_______________________________________________
perfmon2-devel mailing list
perfmon2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/perfmon2-devel

Reply via email to