Fix pointer casts incompatible with 64 bit architectures 69/19269/1
authorIlya Palachev <i.palachev@samsung.com>
Wed, 9 Apr 2014 17:17:51 +0000 (21:17 +0400)
committerIlya Palachev <i.palachev@samsung.com>
Wed, 9 Apr 2014 17:19:08 +0000 (21:19 +0400)
Tizen toolchain team in Samsung company is planning to build Tizen
for new arm 64 bit architecture - Aarch64. But package
"ug-image-viewer-efl" cannot be built for this architecture
because of build errors of the following type:

error: cast from pointer to integer of different size

error: cast from 'void*' to 'int' loses precision

The reason that there are several casts from pointer type to type
(int) in the current implementation of package. These casts
are correct for 32-bit architectures, since on them both pointer
types and (int) have the same size - 32 bits. But on 64-bit
architectures pointer types have size 64 bit and (int) has size
32 bit, and cast from one to another can provide incorrect results.

This problem can be fixed just by simple replacement of (int)
variables with (size_t) variables, since it does not change the logic
of code and provide additional compatibility with 64-bit
architectures. This fix does not affect external API functions,
since only types of local variables and prototypes of static
functions are changed.

Also options "-mfpu=neon" and "-mfloat-abi=softfp" are not recognized
by GCC if aarch64 is the target architecture. The replacements of
these options are "simd" and "fp" suffixes for option "-march".

Also execstack command does not work for aarch64 binaries, since
aarch64 support is not included to version of execstack used in
Tizen. That's why we have disabled this command just for the case of
aarch64.

The patch has been checked for build compatibility under armv7l, i586
and aarch64 architectures and build results are available at
https://build.tizen.org/package/show?package=ug-image-viewer-efl&project=devel%3Aarm_toolchain%3AMobile%3AMain

Change-Id: Ia476533b6b8c45ffb655db96e09d0c7ea2cde912
Signed-off-by: Ilya Palachev <i.palachev@samsung.com>
main/src/control/ivug-crop-ug.cpp
main/src/slider/ivug-slider-item.cpp
main/src/view/ivug-crop-view.cpp
main/src/view/ivug-main-view-menu.cpp
main/src/view/ivug-main-view.cpp
main/src/view/ivug-setas-view-callerid.cpp
main/src/view/ivug-setas-view-wallpaper.cpp
main/src/view/ivug-slideshow-view.cpp
packaging/ug-image-viewer-efl.spec
slideshow/src/control/ivug-slideshow.cpp
widget/src/scissorbox/ScissorBox.cpp

index b6cf52e..a489f56 100755 (executable)
@@ -91,10 +91,10 @@ static void _ivug_setas_crop_view_ok_clicked_cb(void *data, Evas_Object *obj, vo
 
        // do not insert to db
 
-       int setas_data = (int)evas_object_data_get(obj, "setas_type");
+       size_t setas_data = (size_t)evas_object_data_get(obj, "setas_type");
        ivug_set_screen_type type = (ivug_set_screen_type)setas_data;
 
-       int setas_mode = (int)evas_object_data_get(obj, "setas_mode");
+       size_t setas_mode = (size_t)evas_object_data_get(obj, "setas_mode");
        ivug_setas_mode mode = (ivug_setas_mode)setas_mode;
 
        const char* homescreen_path = IVUG_HOME_SCREEN_PATH;
@@ -208,7 +208,7 @@ _show_exit_popup( Evas_Object *parent, const char *title, const char *desc, void
 static void
 _on_msg_load_failed(void *data, Evas_Object *obj, void *event_info)
 {
-       int error = (int)event_info;
+       size_t error = (size_t)event_info;
 
        const char *szMsg = NULL;
 
index b03ea46..991549e 100755 (executable)
@@ -356,7 +356,7 @@ _photocam_loaded_cb(void *data, Evas_Object *obj, void *event_info)
        } Evas_Load_Error; /**< Load error you can get from loading of files - see evas_load_error_str() too */
 #endif
 
-       Evas_Load_Error error = static_cast<Evas_Load_Error>(reinterpret_cast<int>(event_info));
+       Evas_Load_Error error = static_cast<Evas_Load_Error>(reinterpret_cast<size_t>(event_info));
 //     Evas_Load_Error error = evas_object_image_load_error_get(ivug_image_internal_image_get(si->photocam));
 
        if ( error != EVAS_LOAD_ERROR_NONE )
index 91e9e61..df924a4 100755 (executable)
@@ -245,7 +245,7 @@ _ivug_crop_view_response_cb( void *data, Evas_Object *obj, void *event_info )
        IV_ASSERT(obj != NULL);
        IV_ASSERT(data != NULL);
 
-       MSG_HIGH( "response callback=%d",(int)event_info);
+       MSG_HIGH( "response callback=%d", (size_t)event_info);
        IvugCropView *pCropView = static_cast<IvugCropView *>(data);
 
        evas_object_hide(obj);          // popup
index 2f79cc3..0f9917d 100755 (executable)
@@ -356,7 +356,7 @@ static void _ivug_setas_view_ok_clicked_cb(void *data, Evas_Object *obj, void *e
 
        // do not insert to db
 
-       int setas_data = (int)evas_object_data_get(obj, "setas_type");
+       size_t setas_data = (size_t)evas_object_data_get(obj, "setas_type");
        ivug_set_screen_type type = (ivug_set_screen_type)setas_data;
 
        const char* homescreen_path = IVUG_HOME_SCREEN_PATH;
@@ -664,7 +664,7 @@ _on_delete_selected(void *data, Evas_Object *obj, void *event_info)
        Ivug_MainView *pMainView = (Ivug_MainView *)data;
        IV_ASSERT(pMainView != NULL);
 
-       int response_id = (int)event_info;
+       size_t response_id = (size_t)event_info;
        if(response_id == POPUP_RESPONSE_CANCEL)
        {
                MSG_MAIN_HIGH("cancel selected");
@@ -691,7 +691,7 @@ _on_delete_selected(void *data, Evas_Object *obj, void *event_info)
 static void
 _on_rename_selected(void *data, Evas_Object *obj, void *event_info)
 {
-       int response_id = (int)event_info;
+       size_t response_id = (size_t)event_info;
        IV_ASSERT(data != NULL);
 
        Ivug_MainView *pMainView = (Ivug_MainView *)data;
index 2433bad..c69178c 100755 (executable)
@@ -71,7 +71,7 @@
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 //
 //
-static bool _destory_slideshow_and_ug(Ivug_MainView *pMainView, int state, bool bMmc_out);
+static bool _destory_slideshow_and_ug(Ivug_MainView *pMainView, size_t state, bool bMmc_out);
 static void _on_slideshow_finished(void *data, Evas_Object *obj, void *event_info);
 
 void _update_title(Ivug_MainView *pMainView)
@@ -128,7 +128,7 @@ _on_longpress_popup_selected(void *data, Evas_Object *obj, void *event_info)
 // Destroy copy popup
        pMainView->longpress_popup = NULL;              // object is removed automatically
 
-       int response = (int)event_info;
+       size_t response = (size_t)event_info;
 
        Media_Item *mtiem = ivug_slider_get_item(pMainView->slider);
        Media_Data *mdata = ivug_medialist_get_data(mtiem);
@@ -241,7 +241,7 @@ static void _on_resize(void *data, Evas *e, Evas_Object *obj, void *event_info)
 }
 
 static bool _destory_slideshow_and_ug(Ivug_MainView *pMainView,
-       int state,
+       size_t state,
        bool bMmc_out)
 {
        IV_ASSERT(pMainView != NULL);
@@ -365,7 +365,7 @@ static void _update_main_view(Ivug_MainView *pMainView)
 static void
 _ivug_main_drm_popup_purchase_cb(void *data, Evas_Object *obj, void *event_info)
 {
-       int response_id = (int)event_info;
+       size_t response_id = (size_t)event_info;
        IV_ASSERT(data != NULL);
 
        Ivug_MainView *pMainView = (Ivug_MainView *)data;
@@ -407,7 +407,7 @@ _ivug_main_drm_popup_purchase_cb(void *data, Evas_Object *obj, void *event_info)
 static void
 _ivug_main_drm_popup_response_cb(void *data, Evas_Object *obj, void *event_info)
 {
-       int response_id = (int)event_info;
+       size_t response_id = (size_t)event_info;
        IV_ASSERT(data != NULL);
 
        Ivug_MainView *pMainView = (Ivug_MainView *)data;
@@ -656,7 +656,7 @@ _on_slider_long_press_end(void *data, Evas_Object *obj, void *event_info)
                pMainView->popup_timer = NULL;
        }
 
-       if((int)event_info == LONGTAP_CANCELED)
+       if((size_t)event_info == LONGTAP_CANCELED)
        {
                if(pMainView->longpress_popup)
                {
@@ -1040,7 +1040,7 @@ _on_slideshow_finished(void *data, Evas_Object *obj, void *event_info)
        IV_ASSERT(data != NULL);
 
        Ivug_MainView *pMainView = (Ivug_MainView *)data;
-       int ss_state = (int)event_info;
+       size_t ss_state = (size_t)event_info;
        bool bDestoryed = false;
        bDestoryed = _destory_slideshow_and_ug(pMainView, ss_state, false);
        if (bDestoryed) {
index 58f51c2..2cbd6b9 100755 (executable)
@@ -223,7 +223,7 @@ _on_photocam_loaded(void *data, Evas_Object *obj, void *event_info)
        } Evas_Load_Error; /**< Load error you can get from loading of files - see evas_load_error_str() too */
 #endif
 
-       Evas_Load_Error error = static_cast<Evas_Load_Error>((int)event_info);
+       Evas_Load_Error error = static_cast<Evas_Load_Error>((size_t)event_info);
 
        if ( error != EVAS_LOAD_ERROR_NONE )
        {
index 3f821a2..19ee034 100755 (executable)
@@ -85,7 +85,7 @@ _on_photocam_loaded(void *data, Evas_Object *obj, void *event_info)
        } Evas_Load_Error; /**< Load error you can get from loading of files - see evas_load_error_str() too */
 #endif
 
-       Evas_Load_Error error = static_cast<Evas_Load_Error>((int)event_info);
+       Evas_Load_Error error = static_cast<Evas_Load_Error>((size_t)event_info);
 
        if ( error != EVAS_LOAD_ERROR_NONE )
        {
index 89fcbf7..66eec8d 100755 (executable)
@@ -67,7 +67,7 @@ _send_result(ui_gadget_h ug, const char *key1, const char *val1, const char *key
 
 
 static bool _destory_slideshow_and_ug(Ivug_SlideShowView *pSSView,
-       int state,
+       size_t state,
        bool bMmc_out)
 {
        IV_ASSERT(pSSView != NULL);
@@ -152,7 +152,7 @@ _on_slideshow_finished(void *data, Evas_Object *obj, void *event_info)
 
        Ivug_SlideShowView *pSSView = static_cast<Ivug_SlideShowView *>(data);
 
-       int ss_state = (int)event_info;
+       size_t ss_state = (size_t) event_info;
        bool bDestoryed = false;
        bDestoryed = _destory_slideshow_and_ug(pSSView, ss_state, false);
 }
index 0eec7d7..223331a 100755 (executable)
@@ -59,6 +59,10 @@ CXXFLAGS+=%cxxflags
 
 %ifarch %{arm}
 %define ARCH arm
+%ifarch aarch64
+CXXFLAGS+=" -D_ARCH_ARM -march=armv8-a+fp+simd"
+CFLAGS+=" -D_ARCH_ARM -march=armv8-a+fp+simd"
+%else
 CXXFLAGS+=" -D_ARCH_ARM_ -mfpu=neon -mfloat-abi=softfp "
 CFLAGS+=" -D_ARCH_ARM_ -mfpu=neon -mfloat-abi=softfp "
 %else
@@ -78,7 +82,9 @@ rm -rf %{buildroot}
 %make_install
 mkdir -p %{buildroot}/usr/share/license
 
+%ifnarch aarch64
 execstack -c %{buildroot}%{_ugdir}/lib/libug-image-viewer-efl.so.0.1.0
+%endif
 
 %post
 chown -R 5000:5000 %{_datadir}/ug-image-viewer-efl
index 7b48718..e113346 100755 (executable)
@@ -562,7 +562,7 @@ _ivug_ss_photocam_loaded_cb(void *data, Evas_Object *obj, void *event_info)
                return;
        }
 
-       Evas_Load_Error error = static_cast<Evas_Load_Error>(reinterpret_cast<int>(event_info));
+       Evas_Load_Error error = static_cast<Evas_Load_Error>(reinterpret_cast<size_t>(event_info));
        if ( error != EVAS_LOAD_ERROR_NONE )
        {
                MSG_HIGH("Photocam Pre-loaded. File=%s", ivug_get_filename(mdata->filepath));
index 755ac76..0d5e4de 100755 (executable)
@@ -145,7 +145,7 @@ public:
 
                Evas_Event_Mouse_Move *ev = (Evas_Event_Mouse_Move *) event_info;
 
-               eGripType grip = static_cast<eGripType> (reinterpret_cast<int>\r(evas_object_data_get(obj, "grip_type")));
+               eGripType grip = static_cast<eGripType> (reinterpret_cast<size_t>\r(evas_object_data_get(obj, "grip_type")));
 
                if ( ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD )
                {
@@ -758,7 +758,7 @@ public:
 
                Evas_Event_Mouse_Move *ev = (Evas_Event_Mouse_Move *) event_info;
 
-               eGripType grip = static_cast<eGripType> (reinterpret_cast<int>\r(evas_object_data_get(obj, "grip_type")));
+               eGripType grip = static_cast<eGripType> (reinterpret_cast<size_t>\r(evas_object_data_get(obj, "grip_type")));
 
                if ( ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD )
                {