Changeset d923fca for tests/concurrency/pthread/pthread_key_test.cfa
- Timestamp:
- Feb 18, 2025, 12:54:23 PM (6 weeks ago)
- Branches:
- master
- Children:
- 8705a11
- Parents:
- 3e5fea2
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified tests/concurrency/pthread/pthread_key_test.cfa ¶
r3e5fea2 rd923fca 16 16 #define BUFFSZ 48 17 17 pthread_key_t key; 18 volatile int total_value,total_value_getspec; 18 volatile size_t total_value; 19 volatile size_t total_value_getspec; 19 20 pthread_mutex_t value_mutex; 20 21 … … 26 27 int *tnum; 27 28 void *getvalue; 28 char Buffer[BUFFSZ];29 29 30 30 tnum = (int*)parm; … … 32 32 33 33 //printf("Thread %d executing\n", threadnum); 34 value = (void *)( rand()%100);34 value = (void *)(size_t)(rand()%100); 35 35 status = pthread_setspecific(key, (void *) value); 36 36 if ( status != 0) { … … 40 40 } 41 41 pthread_mutex_lock(&value_mutex); 42 total_value_getspec += ( int)value;43 total_value += ( int)pthread_getspecific(key);42 total_value_getspec += (size_t)value; 43 total_value += (size_t)pthread_getspecific(key); 44 44 pthread_mutex_unlock(&value_mutex); 45 45 46 46 47 if (!(value = malloc( sizeof(Buffer))))47 if (!(value = malloc(BUFFSZ))) 48 48 printf("Thread %d could not allocate storage, errno = %d\n", 49 49 threadnum, errno); … … 60 60 61 61 if (getvalue != value) { 62 printf("getvalue not valid, getvalue=%d", (u_int64_t)getvalue);62 printf("getvalue not valid, getvalue=%p", getvalue); 63 63 return (void*)68; 64 64 } … … 76 76 77 77 int main() { 78 int getvalue;79 78 int status; 80 79 int i; … … 116 115 117 116 if (thread_stat[i] != 0) { 118 printf("bad thread status, thread %d, status=% d\n", i+1,119 ( u_int64_t)thread_stat[i]);117 printf("bad thread status, thread %d, status=%zd\n", i+1, 118 (size_t)thread_stat[i]); 120 119 } 121 120 } 122 printf("total value is % d, total value by pthread_getspecific is %d\n", total_value, total_value_getspec);121 printf("total value is %zd, total value by pthread_getspecific is %zd\n", total_value, total_value_getspec); 123 122 exit(0); 124 123 } // main
Note: See TracChangeset
for help on using the changeset viewer.