This patch disables the try-catch feature to build powertop natively on
android. stlport of Android is being used currently to build powertop natively.
Porting powertop to ndk could be one solution. This patch can be disabled
by removing the  DISABLE_TRYCATCH flag in the Android.mk file.

Signed-off-by: John Mathew <[email protected]>
---
 Android.mk       |    2 +-
 devices/ahci.cpp |   11 ++++++++---
 devices/alsa.cpp |   11 ++++++++---
 devices/device.h |    4 ++++
 4 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/Android.mk b/Android.mk
index 05afeba..146f57a 100644
--- a/Android.mk
+++ b/Android.mk
@@ -10,7 +10,7 @@ LOCAL_MODULE := powertop
 
 #LOCAL_CFLAGS += -Wall -O2 -g -fno-omit-frame-pointer -fstack-protector 
-Wshadow -Wformat -D_FORTIFY_SOURCE=2
 #LOCAL_CPPFLAGS += -Wall -O2 -g -fno-omit-frame-pointer
-LOCAL_CPPFLAGS += -DDISABLE_NCURSES -DDISABLE_I18N
+LOCAL_CPPFLAGS += -DDISABLE_NCURSES -DDISABLE_I18N -DDISABLE_TRYCATCH
 
 LOCAL_C_INCLUDES += external/stlport/stlport/ external/stlport/stlport/stl 
external/stlport/stlport/using/h/  bionic external/libnl/include/
 
diff --git a/devices/ahci.cpp b/devices/ahci.cpp
index fb8ac70..34fac0d 100644
--- a/devices/ahci.cpp
+++ b/devices/ahci.cpp
@@ -168,8 +168,11 @@ void ahci::start_measurement(void)
                                file >> start_slumber;
                }       
                file.close();
-       } catch (std::ios_base::failure c) {
        }
+#ifndef DISABLE_TRYCATCH
+       catch (std::ios_base::failure c) {
+       }
+#endif
 
 }
 
@@ -199,9 +202,11 @@ void ahci::end_measurement(void)
                        file >> end_slumber;
                }
                file.close();
-       } catch (std::ios_base::failure c) {
        }
-
+#ifndef DISABLE_TRYCATCH
+       catch (std::ios_base::failure c) {
+       }
+#endif
        if (end_active < start_active)
                end_active = start_active;
 
diff --git a/devices/alsa.cpp b/devices/alsa.cpp
index 5100c36..9f56826 100644
--- a/devices/alsa.cpp
+++ b/devices/alsa.cpp
@@ -101,9 +101,12 @@ void alsa::start_measurement(void)
                        file >> start_active;
                }
                file.close();
-       } catch (std::ios_base::failure &c) {
+       } 
+#ifndef DISABLE_TRYCATCH
+       catch (std::ios_base::failure &c) {
                fprintf(stderr, "%s\n", c.what());
        }
+#endif
 
 }
 
@@ -127,10 +130,12 @@ void alsa::end_measurement(void)
                        file >> end_active;
                }
                file.close();
-       } catch (std::ios_base::failure &c) {
+       }
+#ifndef DISABLE_TRYCATCH
+       catch (std::ios_base::failure &c) {
                fprintf(stderr, "%s\n", c.what());
        }
-
+#endif
 
        p = (end_active - start_active) / (0.001 + end_active + end_inactive - 
start_active - start_inactive) * 100.0;
        report_utilization(name, p);
diff --git a/devices/device.h b/devices/device.h
index a46165b..35fc4d8 100644
--- a/devices/device.h
+++ b/devices/device.h
@@ -32,6 +32,10 @@
 struct parameter_bundle;
 struct result_bundle;
 
+#ifdef DISABLE_TRYCATCH
+#define try            if(1)
+#endif
+
 class device {
 public:
        int cached_valid;
-- 
1.7.1

---------------------------------------------------------------------
Intel Corporation SAS (French simplified joint stock company)
Registered headquarters: "Les Montalets"- 2, rue de Paris, 
92196 Meudon Cedex, France
Registration Number:  302 456 199 R.C.S. NANTERRE
Capital: 4,572,000 Euros

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.

_______________________________________________
Power mailing list
[email protected]
https://bughost.org/mailman/listinfo/power

Reply via email to