You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2020/02/15 15:55:42 UTC
[incubator-nuttx-apps] branch master updated: apps/examples/elf:
Resolve issue issue 63
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx-apps.git
The following commit(s) were added to refs/heads/master by this push:
new 1d8b738 apps/examples/elf: Resolve issue issue 63
1d8b738 is described below
commit 1d8b738a2b6168dd51b7b800affc8969baaca435
Author: Gregory Nutt <gn...@nuttx.org>
AuthorDate: Sat Feb 15 09:50:18 2020 -0600
apps/examples/elf: Resolve issue issue 63
---
examples/elf/tests/mutex/mutex.c | 2 +-
examples/elf/tests/pthread/pthread.c | 24 +++++++++++++++---------
2 files changed, 16 insertions(+), 10 deletions(-)
diff --git a/examples/elf/tests/mutex/mutex.c b/examples/elf/tests/mutex/mutex.c
index 1e6101d..9453f0d 100644
--- a/examples/elf/tests/mutex/mutex.c
+++ b/examples/elf/tests/mutex/mutex.c
@@ -64,7 +64,7 @@ static volatile bool bendoftest;
void thread_func(void *parameter)
{
- intptr_t my_id = (intptr_t)parameter;
+ int my_id = (int)((intptr_t)parameter;)
int my_ndx = my_id - 1;
int i;
diff --git a/examples/elf/tests/pthread/pthread.c b/examples/elf/tests/pthread/pthread.c
index 6288b21..74d12f8 100644
--- a/examples/elf/tests/pthread/pthread.c
+++ b/examples/elf/tests/pthread/pthread.c
@@ -75,23 +75,25 @@ enum exit_values_e
* Private Functions
****************************************************************************/
-/* NOTE: it is necessary for functions that are referred to by function pointers
- * pointer to be declared with global scope (at least for ARM). Otherwise,
- * a relocation type that is not supported by ELF is generated by GCC.
+/* NOTE: it is necessary for functions that are referred to by function
+ * pointers pointer to be declared with global scope (at least for ARM).
+ * Otherwise, a relocation type that is not supported by ELF is generated
+ * by GCC.
*/
void *child_start_routine(void *arg)
{
- printf("CHILD: started with arg=%d\n", (intptr_t)arg);
+ printf("CHILD: started with arg=%d\n", (int)((intptr_t)arg));
if (arg != CHILD_ARG)
{
- printf("CHILD: expected arg=%d\n", (intptr_t)CHILD_ARG);
+ printf("CHILD: expected arg=%d\n", (int)((intptr_t)CHILD_ARG));
return (void*)TESTRESULT_CHILD_ARG_FAIL;
}
+
sleep(2);
- printf("CHILD: returning %d\n", (intptr_t)CHILD_RET);
+ printf("CHILD: returning %d\n", (int)((intptr_t)CHILD_RET));
pthread_exit(CHILD_RET);
}
@@ -115,7 +117,9 @@ int main(int argc, char **argv)
exit(TESTRESULT_PTHREAD_ATTR_INIT_FAIL);
}
- printf("PARENT: calling pthread_start with arg=%d\n", (intptr_t)CHILD_ARG);
+ printf("PARENT: calling pthread_start with arg=%d\n",
+ (int)((intptr_t)CHILD_ARG));
+
status = pthread_create(&thread, &attr, child_start_routine, CHILD_ARG);
if (status != 0)
{
@@ -131,10 +135,12 @@ int main(int argc, char **argv)
exit(TESTRESULT_PTHREAD_JOIN_FAIL);
}
- printf("PARENT child exitted with %d\n", (intptr_t)retval);
+ printf("PARENT child exitted with %d\n", (int)((intptr_t)retval));
if (retval != CHILD_RET)
{
- printf("PARENT child thread did not exit with %d\n", (intptr_t)CHILD_RET);
+ printf("PARENT child thread did not exit with %d\n",
+ (int)((intptr_t)CHILD_RET));
+
exit(TESTRESULT_CHILD_RETVAL_FAIL);
}