Advertisement
Guest User

Untitled

a guest
Jun 19th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 5.89 KB | None | 0 0
  1. commit 4b49fe3778af68eeddffa11000464421e7ad83a9
  2. Author: mread <qt-info@nokia.com>
  3. Date:   Fri Oct 8 15:31:09 2010 +0100
  4.  
  5.     Making the hybrid allocator change compatible across all 4.7.x
  6.  
  7.     The hybrid allocator introduced a new export to qtcore.dll and made
  8.     all apps link to it when they linked with the corresponding qtmain.lib.
  9.     However, this made all apps depend on this new export, and since that
  10.     export is not present in early 4.7.x release, these apps would not run
  11.     with the Qt DLLs from those releases, which breaks Qt's compatibility
  12.     guarantees for patch releases. This change makes apps compatible with
  13.     all 4.7.x releases again.
  14.  
  15.     For export frozen Qt builds (the sort that should be compatible across
  16.     all 4.7.x releases), qtmain.lib no longer forces a static import link
  17.     to qt_symbian_SetupThreadHeap(). Instead it dynamically loads
  18.     qtcore.dll, looks up qt_symbian_SetupThreadHeap(), and calls it if
  19.     present. If the function is not present, or on emulator builds where we
  20.     know that qtcore will use the system allocator creation function, we
  21.     call the system allocator creation function.
  22.  
  23.     For export unfrozen builds, there is no compatibility between builds or
  24.     releases, so we do use a static import link to
  25.     qt_symbian_SetupThreadHeap(), as we have to use the qtcore dll we have
  26.     built with it anyway.
  27.  
  28.     *** This change is only required for 4.7. It is not needed for 4.8+ ***
  29.     *** If this change appears in 4.8+, it can be reverted.             ***
  30.  
  31.     Task-number: QT-4080
  32.     Reviewed-by: ?
  33.  
  34. diff --git a/src/s60main/newallocator_hook.cpp b/src/s60main/newallocator_hook.cpp
  35. index 9cc6afb..9ea2ef0 100644
  36. --- a/src/s60main/newallocator_hook.cpp
  37. +++ b/src/s60main/newallocator_hook.cpp
  38. @@ -41,6 +41,11 @@
  39.  #include <e32std.h>
  40.  #include <qglobal.h>
  41.  
  42. +#ifdef QT_EXPORTS_NOT_FROZEN
  43. +// If exports in Qt DLLs are not frozen in this build, then we have to pick up the
  44. +// allocator creation function by import link. We know the function will be present
  45. +// in the DLLs we test with, as we have to use the DLLs we have built.
  46. +
  47.  struct SStdEpocThreadCreateInfo;
  48.  
  49.  Q_CORE_EXPORT TInt qt_symbian_SetupThreadHeap(TBool aNotFirst, SStdEpocThreadCreateInfo& aInfo);
  50. @@ -51,8 +56,88 @@ Q_CORE_EXPORT TInt qt_symbian_SetupThreadHeap(TBool aNotFirst, SStdEpocThreadCre
  51.   * Uses link-time symbol preemption to capture a call from the application
  52.   * startup. On return, there is some kind of heap allocator installed on the
  53.   * thread.
  54. -*/
  55. +*/
  56.  TInt UserHeap::SetupThreadHeap(TBool aNotFirst, SStdEpocThreadCreateInfo& aInfo)
  57.  {
  58.      return qt_symbian_SetupThreadHeap(aNotFirst, aInfo);
  59.  }
  60. +
  61. +#else // QT_EXPORTS_NOT_FROZEN
  62. +// If we are using an export frozen build, it should be compatible with all 4.7.x Qt releases.
  63. +// We want to use the allocator creation function introduced in qtcore.dll after 4.7.1. But we
  64. +// can't import link to it, as it may not be present in whatever 4.7.x DLLs we are running with.
  65. +// So the function is found and called dynamically, by library lookup. If it is not found, we
  66. +// use the OS allocator creation functions instead.
  67. +
  68. +struct SThreadCreateInfo
  69. +    {
  70. +    TAny* iHandle;
  71. +    TInt iType;
  72. +    TThreadFunction iFunction;
  73. +    TAny* iPtr;
  74. +    TAny* iSupervisorStack;
  75. +    TInt iSupervisorStackSize;
  76. +    TAny* iUserStack;
  77. +    TInt iUserStackSize;
  78. +    TInt iInitialThreadPriority;
  79. +    TPtrC iName;
  80. +    TInt iTotalSize;    // Size including any extras (must be a multiple of 8 bytes)
  81. +    };
  82. +
  83. +struct SStdEpocThreadCreateInfo : public SThreadCreateInfo
  84. +    {
  85. +    RAllocator* iAllocator;
  86. +    TInt iHeapInitialSize;
  87. +    TInt iHeapMaxSize;
  88. +    TInt iPadding;      // Make structure size a multiple of 8 bytes
  89. +    };
  90. +
  91. +
  92. +/* \internal
  93. + *
  94. + * Uses link-time symbol preemption to capture a call from the application
  95. + * startup. On return, there is some kind of heap allocator installed on the
  96. + * thread.
  97. +*/
  98. +TInt UserHeap::SetupThreadHeap(TBool aNotFirst, SStdEpocThreadCreateInfo& aInfo)
  99. +{
  100. +    TInt r = KErrNone;
  101. +
  102. +#ifndef __WINS__
  103. +    // attempt to create the fast allocator through a known export ordinal in qtcore.dll
  104. +    RLibrary qtcore;
  105. +    if (qtcore.Load(_L("qtcore.dll")) == KErrNone)
  106. +    {
  107. +        const int qt_symbian_SetupThreadHeap_eabi_ordinal = 3713;
  108. +        TLibraryFunction libFunc = qtcore.Lookup(qt_symbian_SetupThreadHeap_eabi_ordinal);
  109. +        if (libFunc)
  110. +        {
  111. +            typedef int (*TSetupThreadHeapFunc)(TBool aNotFirst, SStdEpocThreadCreateInfo& aInfo);
  112. +            TSetupThreadHeapFunc p_qt_symbian_SetupThreadHeap = TSetupThreadHeapFunc(libFunc);
  113. +            r = (*p_qt_symbian_SetupThreadHeap)(aNotFirst, aInfo);
  114. +        }
  115. +        qtcore.Close();
  116. +        if (libFunc)
  117. +            return r;
  118. +    }
  119. +#endif
  120. +
  121. +    // no fast allocator support - use default allocator creation
  122. +    if (!aInfo.iAllocator && aInfo.iHeapInitialSize>0)
  123. +        {
  124. +        // new heap required
  125. +        RHeap* pH = NULL;
  126. +        r = UserHeap::CreateThreadHeap(aInfo, pH);
  127. +        }
  128. +    else if (aInfo.iAllocator)
  129. +        {
  130. +        // sharing a heap
  131. +        RAllocator* pA = aInfo.iAllocator;
  132. +        pA->Open();
  133. +        User::SwitchAllocator(pA);
  134. +        r = KErrNone;
  135. +        }
  136. +    return r;
  137. +}
  138. +
  139. +#endif // QT_EXPORTS_NOT_FROZEN
  140. diff --git a/src/s60main/s60main.pro b/src/s60main/s60main.pro
  141. index 664f155..8ab3bd3 100644
  142. --- a/src/s60main/s60main.pro
  143. +++ b/src/s60main/s60main.pro
  144. @@ -31,6 +31,9 @@ symbian {
  145.      # against GCCE apps, so remove it
  146.      MMP_RULES -= $$MMP_RULES_DONT_EXPORT_ALL_CLASS_IMPEDIMENTA
  147.      linux-armcc:QMAKE_CXXFLAGS *= --export_all_vtbl
  148. +
  149. +    # Flag if exports are not frozen to avoid lookup of qtcore allocator creation function by ordinal
  150. +    contains(CONFIG, def_files_disabled): DEFINES += QT_EXPORTS_NOT_FROZEN
  151.  } else {
  152.      error("$$_FILE_ is intended only for Symbian!")
  153.  }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement