OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // mini_installer.exe is the first exe that is run when chrome is being | 5 // mini_installer.exe is the first exe that is run when chrome is being |
6 // installed or upgraded. It is designed to be extremely small (~5KB with no | 6 // installed or upgraded. It is designed to be extremely small (~5KB with no |
7 // extra resources linked) and it has two main jobs: | 7 // extra resources linked) and it has two main jobs: |
8 // 1) unpack the resources (possibly decompressing some) | 8 // 1) unpack the resources (possibly decompressing some) |
9 // 2) run the real installer (setup.exe) with appropriate flags. | 9 // 2) run the real installer (setup.exe) with appropriate flags. |
10 // | 10 // |
(...skipping 816 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
827 // simply implement memset. | 827 // simply implement memset. |
828 // | 828 // |
829 // This also avoids having to explicitly set the __sse2_available hack when | 829 // This also avoids having to explicitly set the __sse2_available hack when |
830 // linking with both the x64 and x86 obj files which is required when not | 830 // linking with both the x64 and x86 obj files which is required when not |
831 // linking with the std C lib in certain instances (including Chromium) with | 831 // linking with the std C lib in certain instances (including Chromium) with |
832 // MSVC. __sse2_available determines whether to use SSE2 intructions with | 832 // MSVC. __sse2_available determines whether to use SSE2 intructions with |
833 // std C lib routines, and is set by MSVC's std C lib implementation normally. | 833 // std C lib routines, and is set by MSVC's std C lib implementation normally. |
834 extern "C" { | 834 extern "C" { |
835 #pragma function(memset) | 835 #pragma function(memset) |
836 void* memset(void* dest, int c, size_t count) { | 836 void* memset(void* dest, int c, size_t count) { |
837 // Simplistic 32-bit memset C implementation which assumes properly aligned | 837 void* start = dest; |
838 // memory; performance hit on memory that isn't properly aligned, but still | 838 while (count--) { |
839 // better overall then a 8-bit implementation. | 839 *reinterpret_cast<char*>(dest) = static_cast<char>(val); |
grt (UTC plus 2)
2014/05/20 23:04:04
val -> c?
scottmg
2014/05/20 23:55:57
Urgh. :( Thanks.
I also confirm that I can reprod
| |
840 size_t adjcount = count >> 2; | 840 dest = reinterpret_cast<char*>(dest) + 1; |
841 UINT32 fill = (c << 24 | c << 16 | c << 8 | c); | |
842 UINT32* dest32 = reinterpret_cast<UINT32*>(dest); | |
843 UINT8* dest8 = reinterpret_cast<UINT8*>(dest); | |
844 | |
845 // Take care of the ending 0-3 bytes (binary 11 = 3). The lack of breaks is | |
846 // deliberate; it falls through for each byte. Think of it a simplified for | |
847 // loop. | |
848 switch (count - (adjcount << 2)) { | |
849 case 3: | |
850 dest8[count - 3] = c; | |
851 case 2: | |
852 dest8[count - 2] = c; | |
853 case 1: | |
854 dest8[count - 1] = c; | |
855 } | 841 } |
856 | 842 return start; |
857 while (adjcount-- > 0) // Copy the rest, 4 bytes/32 bits at a time | |
858 *(dest32++) = fill; | |
859 | |
860 return dest; | |
861 } | |
862 } // extern "C" | 843 } // extern "C" |
OLD | NEW |