| 44 | } |
| 45 | |
| 46 | static void * |
| 47 | thd_start(void *arg) { |
| 48 | int d = (int)(uintptr_t)arg; |
| 49 | void *p; |
| 50 | |
| 51 | tsd_t *tsd = tsd_fetch(); |
| 52 | assert_x_eq(tsd_test_data_get(tsd), MALLOC_TSD_TEST_DATA_INIT, |
| 53 | "Initial tsd get should return initialization value"); |
| 54 | |
| 55 | p = malloc(1); |
| 56 | assert_ptr_not_null(p, "Unexpected malloc() failure"); |
| 57 | |
| 58 | tsd_test_data_set(tsd, d); |
| 59 | assert_x_eq(tsd_test_data_get(tsd), d, |
| 60 | "After tsd set, tsd get should return value that was set"); |
| 61 | |
| 62 | d = 0; |
| 63 | assert_x_eq(tsd_test_data_get(tsd), (int)(uintptr_t)arg, |
| 64 | "Resetting local data should have no effect on tsd"); |
| 65 | |
| 66 | tsd_test_callback_set(tsd, &data_cleanup); |
| 67 | |
| 68 | free(p); |
| 69 | return NULL; |
| 70 | } |
| 71 | |
| 72 | TEST_BEGIN(test_tsd_main_thread) { |
| 73 | thd_start((void *)(uintptr_t)0xa5f3e329); |