MCPcopy Create free account
hub / github.com/emscripten-core/emscripten / main

Function main

test/pthread/test_pthread_atomics.c:147–181  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

145}
146
147int main()
148{
149 globalUchar = 4;
150 globalUshort = 4;
151 globalUint = 4;
152 globalFloat = 5.0f;
153 globalDouble = 5.0;
154
155 uint8_t prevUchar = emscripten_atomic_add_u8((void*)&globalUchar, 1); assert(prevUchar == 4);
156 uint16_t prevUshort = emscripten_atomic_add_u16((void*)&globalUshort, 1); assert(prevUshort == 4);
157 uint32_t prevUint = emscripten_atomic_add_u32((void*)&globalUint, 1); assert(prevUint == 4);
158
159 emscripten_atomic_fence();
160 __sync_synchronize();
161
162 for(int i = 0; i < 7; ++i)
163 RunTest(i);
164
165 uint64_t totalRead = 0;
166 uint64_t totalWritten = 0;
167 for(int i = 0; i < NUM_THREADS; ++i)
168 {
169 totalRead += threadCasAccumulatedReadData[i];
170 totalWritten += threadCasAccumulatedWrittenData[i];
171 }
172 for(int i = 0; i < N; ++i)
173 totalRead += sharedData[i];
174 if (totalRead == totalWritten)
175 printf("totalRead: %llu, totalWritten: %llu\n", totalRead, totalWritten);
176 else
177 printf("32-bit CAS test failed! totalRead != totalWritten (%llu != %llu)\n", totalRead, totalWritten);
178 printf("Main: Test successfully finished.\n");
179 assert(totalRead == totalWritten);
180 return 0;
181}

Callers

nothing calls this directly

Calls 7

emscripten_atomic_add_u8Function · 0.85
emscripten_atomic_fenceFunction · 0.85
printfFunction · 0.85
RunTestFunction · 0.70
assertFunction · 0.50

Tested by

no test coverage detected